diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile index 4bc0d006cb98..1d9cb63510f1 100644 --- a/usr.bin/xinstall/Makefile +++ b/usr.bin/xinstall/Makefile @@ -11,6 +11,7 @@ MAN= install.1 .PATH: ${SRCTOP}/contrib/mtree CFLAGS+= -I${SRCTOP}/contrib/mtree CFLAGS+= -I${SRCTOP}/lib/libnetbsd +CFLAGS+= -DHAVE_STRUCT_STAT_ST_FLAGS=1 LIBADD= md diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 15fc2efdf3aa..512ec962d4a1 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -533,9 +533,11 @@ do_link(const char *from_name, const char *to_name, unlink(tmpl); err(EX_OSERR, "%s", to_name); } +#if HAVE_STRUCT_STAT_ST_FLAGS if (target_sb->st_flags & NOCHANGEBITS) (void)chflags(to_name, target_sb->st_flags & ~NOCHANGEBITS); +#endif if (verbose) printf("install: link %s -> %s\n", from_name, to_name); @@ -579,9 +581,11 @@ do_symlink(const char *from_name, const char *to_name, (void)unlink(tmpl); err(EX_OSERR, "%s", to_name); } +#if HAVE_STRUCT_STAT_ST_FLAGS if (target_sb->st_flags & NOCHANGEBITS) (void)chflags(to_name, target_sb->st_flags & ~NOCHANGEBITS); +#endif if (verbose) printf("install: symlink %s -> %s\n", from_name, to_name); @@ -779,9 +783,11 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) if (target && !safecopy) { if (to_sb.st_mode & S_IFDIR && rmdir(to_name) == -1) err(EX_OSERR, "%s", to_name); +#if HAVE_STRUCT_STAT_ST_FLAGS if (to_sb.st_flags & NOCHANGEBITS) (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS); +#endif unlink(to_name); } makelink(from_name, to_name, target ? &to_sb : NULL); @@ -893,9 +899,11 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) * and the files are different (or just not compared). */ if (tempcopy && !files_match) { +#if HAVE_STRUCT_STAT_ST_FLAGS /* Try to turn off the immutable bits. */ if (to_sb.st_flags & NOCHANGEBITS) (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS); +#endif if (dobackup) { if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", to_name, suffix) != strlen(to_name) + strlen(suffix)) { @@ -907,8 +915,10 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) (void)printf("install: %s -> %s\n", to_name, backup); if (unlink(backup) < 0 && errno != ENOENT) { serrno = errno; +#if HAVE_STRUCT_STAT_ST_FLAGS if (to_sb.st_flags & NOCHANGEBITS) (void)chflags(to_name, to_sb.st_flags); +#endif unlink(tempfile); errno = serrno; err(EX_OSERR, "unlink: %s", backup); @@ -916,8 +926,10 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) if (link(to_name, backup) < 0) { serrno = errno; unlink(tempfile); +#if HAVE_STRUCT_STAT_ST_FLAGS if (to_sb.st_flags & NOCHANGEBITS) (void)chflags(to_name, to_sb.st_flags); +#endif errno = serrno; err(EX_OSERR, "link: %s to %s", to_name, backup); @@ -962,9 +974,11 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) if (!dounpriv && ((gid != (gid_t)-1 && gid != to_sb.st_gid) || (uid != (uid_t)-1 && uid != to_sb.st_uid) || (mode != (to_sb.st_mode & ALLPERMS)))) { +#if HAVE_STRUCT_STAT_ST_FLAGS /* Try to turn off the immutable bits. */ if (to_sb.st_flags & NOCHANGEBITS) (void)fchflags(to_fd, to_sb.st_flags & ~NOCHANGEBITS); +#endif } if (!dounpriv & @@ -986,7 +1000,7 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) err(EX_OSERR, "%s: chmod", to_name); } } - +#if HAVE_STRUCT_STAT_ST_FLAGS /* * If provided a set of flags, set them, otherwise, preserve the * flags, except for the dump flag. @@ -1009,6 +1023,7 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) } } } +#endif (void)close(to_fd); if (!devnull) @@ -1135,15 +1150,19 @@ create_newfile(const char *path, int target, struct stat *sbp) * off the append/immutable bits -- if we fail, go ahead, * it might work. */ +#if HAVE_STRUCT_STAT_ST_FLAGS if (sbp->st_flags & NOCHANGEBITS) (void)chflags(path, sbp->st_flags & ~NOCHANGEBITS); +#endif if (dobackup) { if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix) != strlen(path) + strlen(suffix)) { saved_errno = errno; +#if HAVE_STRUCT_STAT_ST_FLAGS if (sbp->st_flags & NOCHANGEBITS) (void)chflags(path, sbp->st_flags); +#endif errno = saved_errno; errx(EX_OSERR, "%s: backup filename too long", path); @@ -1155,8 +1174,10 @@ create_newfile(const char *path, int target, struct stat *sbp) path, backup); if (rename(path, backup) < 0) { saved_errno = errno; +#if HAVE_STRUCT_STAT_ST_FLAGS if (sbp->st_flags & NOCHANGEBITS) (void)chflags(path, sbp->st_flags); +#endif errno = saved_errno; err(EX_OSERR, "rename: %s to %s", path, backup); } diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c index 0682c30c2ae5..14d7714b8dbb 100644 --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -70,6 +70,10 @@ #include __FBSDID("$FreeBSD$"); +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #include @@ -315,7 +319,7 @@ static void ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts) { int32_t ncg = 1; -#if notyet +#ifdef notyet int32_t spc, nspf, ncyl, fssize; #endif ffs_opt_t *ffs_opts = fsopts->fs_specific; diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c index 181a695bcb31..2bcdd6c82254 100644 --- a/usr.sbin/makefs/mtree.c +++ b/usr.sbin/makefs/mtree.c @@ -25,6 +25,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include __FBSDID("$FreeBSD$"); @@ -532,11 +536,13 @@ read_mtree_keywords(FILE *fp, fsnode *node) break; } flset = flclr = 0; +#if HAVE_STRUCT_STAT_ST_FLAGS if (!strtofflags(&value, &flset, &flclr)) { st->st_flags &= ~flclr; st->st_flags |= flset; } else error = errno; +#endif } else error = ENOSYS; break;