diff options
author | msmith <msmith@FreeBSD.org> | 1998-10-20 08:04:15 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-10-20 08:04:15 +0000 |
commit | 83b8dc833cb83cfed89987cdd048b8e45643b372 (patch) | |
tree | 319d42af1c8eb18bd29566146486f5267a35c573 /bin/mkdir | |
parent | 68f507056941cf35219b6b3dc04f80b1f3f89a23 (diff) | |
download | FreeBSD-src-83b8dc833cb83cfed89987cdd048b8e45643b372.zip FreeBSD-src-83b8dc833cb83cfed89987cdd048b8e45643b372.tar.gz |
Make this compile, and honour the spirit of the original design while
incorporating the intended fix. Attempt to address some of the
putative style bugs introduced. Others doubtless remain.
Embarrassed by: bde
Diffstat (limited to 'bin/mkdir')
-rw-r--r-- | bin/mkdir/mkdir.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index e11cfb0..6921701 100644 --- a/bin/mkdir/mkdir.c +++ b/bin/mkdir/mkdir.c @@ -42,7 +42,7 @@ static char const copyright[] = static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94"; #endif static const char rcsid[] = - "$Id: mkdir.c,v 1.11 1998/05/15 06:23:45 charnier Exp $"; + "$Id: mkdir.c,v 1.12 1998/10/20 06:37:01 msmith Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -110,7 +110,7 @@ main(argc, argv) * nine bits, so if you try to set a mode including the * sticky, setuid, setgid bits you lose them. So chmod(). */ - if (chmod(*argv, mode) == -1) { + if (chmod(*argv, omode) == -1) { warn("%s", *argv); exitval = 1; } @@ -170,13 +170,15 @@ build(path, omode) break; } /* - * The mkdir() and umask() calls both honor only the low - * nine bits, so if you try to set a mode including the - * sticky, setuid, setgid bits you lose them. So chmod(). + * The mkdir() and umask() calls both honor only the + * low nine bits, so if you try to set a mode + * including the sticky, setuid, setgid bits you lose + * them. So chmod() the last path component to try + * to do what the caller has asked for. */ - if (chmod(*path, mode) == -1) { - warn("%s", *path); - exitval = 1; + if (last && (chmod(path, omode) == -1)) { + warn("%s", path); + retval = 1; } } else if ((sb.st_mode & S_IFMT) != S_IFDIR) { |