version 1.18, 2015/01/20 09:00:16 |
version 1.19, 2015/01/21 04:08:37 |
|
|
* Normally we want to change /dir1/dir2/file |
* Normally we want to change /dir1/dir2/file |
* into "/dir1/dir2/." |
* into "/dir1/dir2/." |
*/ |
*/ |
if ((p = (char *) strrchr(file, '/')) != NULL) { |
if ((p = strrchr(file, '/')) != NULL) { |
if (strcmp(p, "/.") == 0) { |
if (strcmp(p, "/.") == 0) { |
*p = CNULL; |
*p = CNULL; |
} else { |
} else { |
|
|
} |
} |
|
|
if (statbuf) |
if (statbuf) |
bcopy((char *) &filestat, (char *) statbuf, sizeof(filestat)); |
bcopy(&filestat, statbuf, sizeof(filestat)); |
|
|
/* |
/* |
* Trim the "/." that we added. |
* Trim the "/." that we added. |
|
|
* name in case the symlink points to another filesystem. |
* name in case the symlink points to another filesystem. |
*/ |
*/ |
if (S_ISLNK(filestat.st_mode)) |
if (S_ISLNK(filestat.st_mode)) |
if ((p = (char *) strrchr(file, '/')) && *p+1) { |
if ((p = strrchr(file, '/')) && *p+1) { |
/* Is this / (root)? */ |
/* Is this / (root)? */ |
if (p == file) |
if (p == file) |
file[1] = CNULL; |
file[1] = CNULL; |
|
|
return(*file ? file : NULL); |
return(*file ? file : NULL); |
} |
} |
|
|
#if defined(NFS_CHECK) || defined(RO_CHECK) |
|
|
|
/* |
/* |
* Find the device that "filest" is on in the "mntinfo" linked list. |
* Find the device that "filest" is on in the "mntinfo" linked list. |
|
|
for (mi = mntinfo; mi; mi = mi->mi_nxt) { |
for (mi = mntinfo; mi; mi = mi->mi_nxt) { |
if (mi->mi_mnt->me_flags & MEFLAG_IGNORE) |
if (mi->mi_mnt->me_flags & MEFLAG_IGNORE) |
continue; |
continue; |
if (filest->st_dev == mi->mi_statb->st_dev) |
if (filest->st_dev == mi->mi_dev) |
return(mi->mi_mnt); |
return(mi->mi_mnt); |
} |
} |
|
|
|
|
/* |
/* |
* Create new entry |
* Create new entry |
*/ |
*/ |
newmi = (struct mntinfo *) xcalloc(1, sizeof(struct mntinfo)); |
newmi = xcalloc(1, sizeof(*newmi)); |
newmi->mi_mnt = newmountent(mnt); |
newmi->mi_mnt = newmountent(mnt); |
newmi->mi_statb = |
newmi->mi_dev = mntstat.st_dev; |
(struct stat *) xcalloc(1, sizeof(struct stat)); |
|
bcopy((char *) &mntstat, (char *) newmi->mi_statb, |
|
sizeof(struct stat)); |
|
|
|
/* |
/* |
* Add entry to list |
* Add entry to list |
|
|
return(NULL); |
return(NULL); |
} |
} |
|
|
#endif /* NFS_CHECK || RO_CHECK */ |
|
|
|
#if defined(NFS_CHECK) |
|
/* |
/* |
* Is "path" NFS mounted? Return 1 if it is, 0 if not, or -1 on error. |
* Is "path" NFS mounted? Return 1 if it is, 0 if not, or -1 on error. |
*/ |
*/ |
|
|
|
|
return(0); |
return(0); |
} |
} |
#endif /* NFS_CHECK */ |
|
|
|
#if defined(RO_CHECK) |
|
/* |
/* |
* Is "path" on a read-only mounted filesystem? |
* Is "path" on a read-only mounted filesystem? |
* Return 1 if it is, 0 if not, or -1 on error. |
* Return 1 if it is, 0 if not, or -1 on error. |
|
|
{ |
{ |
mntent_t *mnt; |
mntent_t *mnt; |
|
|
if ((mnt = (mntent_t *) getmntpt(path, statbuf, isvalid)) == NULL) |
if ((mnt = getmntpt(path, statbuf, isvalid)) == NULL) |
return(-1); |
return(-1); |
|
|
if (mnt->me_flags & MEFLAG_READONLY) |
if (mnt->me_flags & MEFLAG_READONLY) |
|
|
|
|
return(0); |
return(0); |
} |
} |
#endif /* RO_CHECK */ |
|
|
|
/* |
/* |
* Is "path" a symlink? |
* Is "path" a symlink? |