diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-01-21 04:08:38 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-01-21 04:08:38 +0000 |
commit | 554ec94adf259352fbc39b4ea2808119a4142f26 (patch) | |
tree | 51a74428ca89f85ba1b38c52a6765a020f3ea93e /usr.bin/rdistd | |
parent | 07e9154deac52d1163030120d5c2cf0803c67af3 (diff) |
Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.
Diffstat (limited to 'usr.bin/rdistd')
-rw-r--r-- | usr.bin/rdistd/filesys.c | 25 | ||||
-rw-r--r-- | usr.bin/rdistd/server.c | 16 | ||||
-rw-r--r-- | usr.bin/rdistd/server.h | 4 |
3 files changed, 13 insertions, 32 deletions
diff --git a/usr.bin/rdistd/filesys.c b/usr.bin/rdistd/filesys.c index 61351815f42..dbbc102f528 100644 --- a/usr.bin/rdistd/filesys.c +++ b/usr.bin/rdistd/filesys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filesys.c,v 1.18 2015/01/20 09:00:16 guenther Exp $ */ +/* $OpenBSD: filesys.c,v 1.19 2015/01/21 04:08:37 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -108,7 +108,7 @@ find_file(char *pathname, struct stat *statbuf, int *isvalid) * Normally we want to change /dir1/dir2/file * into "/dir1/dir2/." */ - if ((p = (char *) strrchr(file, '/')) != NULL) { + if ((p = strrchr(file, '/')) != NULL) { if (strcmp(p, "/.") == 0) { *p = CNULL; } else { @@ -131,7 +131,7 @@ find_file(char *pathname, struct stat *statbuf, int *isvalid) } if (statbuf) - bcopy((char *) &filestat, (char *) statbuf, sizeof(filestat)); + bcopy(&filestat, statbuf, sizeof(filestat)); /* * Trim the "/." that we added. @@ -147,7 +147,7 @@ find_file(char *pathname, struct stat *statbuf, int *isvalid) * name in case the symlink points to another filesystem. */ if (S_ISLNK(filestat.st_mode)) - if ((p = (char *) strrchr(file, '/')) && *p+1) { + if ((p = strrchr(file, '/')) && *p+1) { /* Is this / (root)? */ if (p == file) file[1] = CNULL; @@ -161,7 +161,6 @@ find_file(char *pathname, struct stat *statbuf, int *isvalid) return(*file ? file : NULL); } -#if defined(NFS_CHECK) || defined(RO_CHECK) /* * Find the device that "filest" is on in the "mntinfo" linked list. @@ -174,7 +173,7 @@ findmnt(struct stat *filest, struct mntinfo *mntinfo) for (mi = mntinfo; mi; mi = mi->mi_nxt) { if (mi->mi_mnt->me_flags & MEFLAG_IGNORE) continue; - if (filest->st_dev == mi->mi_statb->st_dev) + if (filest->st_dev == mi->mi_dev) return(mi->mi_mnt); } @@ -253,12 +252,9 @@ makemntinfo(struct mntinfo *mi) /* * Create new entry */ - newmi = (struct mntinfo *) xcalloc(1, sizeof(struct mntinfo)); + newmi = xcalloc(1, sizeof(*newmi)); newmi->mi_mnt = newmountent(mnt); - newmi->mi_statb = - (struct stat *) xcalloc(1, sizeof(struct stat)); - bcopy((char *) &mntstat, (char *) newmi->mi_statb, - sizeof(struct stat)); + newmi->mi_dev = mntstat.st_dev; /* * Add entry to list @@ -330,9 +326,7 @@ getmntpt(char *pathname, struct stat *statbuf, int *isvalid) 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. */ @@ -349,9 +343,7 @@ is_nfs_mounted(char *path, struct stat *statbuf, int *isvalid) return(0); } -#endif /* NFS_CHECK */ -#if defined(RO_CHECK) /* * Is "path" on a read-only mounted filesystem? * Return 1 if it is, 0 if not, or -1 on error. @@ -361,7 +353,7 @@ is_ro_mounted(char *path, struct stat *statbuf, int *isvalid) { mntent_t *mnt; - if ((mnt = (mntent_t *) getmntpt(path, statbuf, isvalid)) == NULL) + if ((mnt = getmntpt(path, statbuf, isvalid)) == NULL) return(-1); if (mnt->me_flags & MEFLAG_READONLY) @@ -369,7 +361,6 @@ is_ro_mounted(char *path, struct stat *statbuf, int *isvalid) return(0); } -#endif /* RO_CHECK */ /* * Is "path" a symlink? diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c index a318ded3f71..885234418d4 100644 --- a/usr.bin/rdistd/server.c +++ b/usr.bin/rdistd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.36 2015/01/21 03:18:31 guenther Exp $ */ +/* $OpenBSD: server.c,v 1.37 2015/01/21 04:08:37 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -546,12 +546,8 @@ docmdspecial(void) /* * Query. Check to see if file exists. Return one of the following: * -#ifdef NFS_CHECK * QC_ONNFS - resides on a NFS -#endif NFS_CHECK -#ifdef RO_CHECK * QC_ONRO - resides on a Read-Only filesystem -#endif RO_CHECK * QC_NO - doesn't exist * QC_YESsize mtime - exists and its a regular file (size & mtime of file) * QC_YES - exists and its a directory or symbolic link @@ -572,7 +568,6 @@ query(char *xname) if (catname && cattarget(name) < 0) return; -#if defined(NFS_CHECK) if (IS_ON(options, DO_CHKNFS)) { s = is_nfs_mounted(target, &stb, &stbvalid); if (s > 0) @@ -585,9 +580,7 @@ query(char *xname) return; } } -#endif /* NFS_CHECK */ -#if defined(RO_CHECK) if (IS_ON(options, DO_CHKREADONLY)) { s = is_ro_mounted(target, &stb, &stbvalid); if (s > 0) @@ -600,7 +593,6 @@ query(char *xname) return; } } -#endif /* RO_CHECK */ if (IS_ON(options, DO_CHKSYM)) { if (is_symlinked(target, &stb, &stbvalid) > 0) { @@ -610,10 +602,8 @@ query(char *xname) } /* - * If stbvalid is false, "stb" is not valid because: - * a) RO_CHECK and NFS_CHECK were not defined - * b) The stat by is_*_mounted() either failed or - * does not match "target". + * If stbvalid is false, "stb" is not valid because the stat() + * by is_*_mounted() either failed or does not match "target". */ if (!stbvalid && lstat(target, &stb) < 0) { if (errno == ENOENT) diff --git a/usr.bin/rdistd/server.h b/usr.bin/rdistd/server.h index 26c7c900a22..4e9e5c4135a 100644 --- a/usr.bin/rdistd/server.h +++ b/usr.bin/rdistd/server.h @@ -1,4 +1,4 @@ -/* $OpenBSD: server.h,v 1.1 2015/01/20 09:00:16 guenther Exp $ */ +/* $OpenBSD: server.h,v 1.2 2015/01/21 04:08:37 guenther Exp $ */ #ifndef __SERVER_H__ #define __SERVER_H__ @@ -65,7 +65,7 @@ typedef struct { */ struct mntinfo { mntent_t *mi_mnt; - struct stat *mi_statb; + dev_t mi_dev; struct mntinfo *mi_nxt; }; |