Deleted Added
full compact
mkdir.c (40602) mkdir.c (40606)
1/*
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 49 unchanged lines hidden (view full) ---

58int build __P((char *, mode_t));
59void usage __P((void));
60
61int
62main(argc, argv)
63 int argc;
64 char *argv[];
65{
1/*
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 49 unchanged lines hidden (view full) ---

58int build __P((char *, mode_t));
59void usage __P((void));
60
61int
62main(argc, argv)
63 int argc;
64 char *argv[];
65{
66 int ch, exitval, omode, pflag;
66 int ch, exitval, success, omode, pflag;
67 mode_t *set = (mode_t *)NULL;
68 char *mode;
69
70 omode = pflag = 0;
71 mode = NULL;
72 while ((ch = getopt(argc, argv, "m:p")) != -1)
73 switch(ch) {
74 case 'p':

--- 16 unchanged lines hidden (view full) ---

91 omode = S_IRWXU | S_IRWXG | S_IRWXO;
92 } else {
93 if ((set = setmode(mode)) == NULL)
94 errx(1, "invalid file mode: %s", mode);
95 omode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
96 }
97
98 for (exitval = 0; *argv != NULL; ++argv) {
67 mode_t *set = (mode_t *)NULL;
68 char *mode;
69
70 omode = pflag = 0;
71 mode = NULL;
72 while ((ch = getopt(argc, argv, "m:p")) != -1)
73 switch(ch) {
74 case 'p':

--- 16 unchanged lines hidden (view full) ---

91 omode = S_IRWXU | S_IRWXG | S_IRWXO;
92 } else {
93 if ((set = setmode(mode)) == NULL)
94 errx(1, "invalid file mode: %s", mode);
95 omode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
96 }
97
98 for (exitval = 0; *argv != NULL; ++argv) {
99 success = 1;
99 if (pflag) {
100 if (build(*argv, omode))
100 if (pflag) {
101 if (build(*argv, omode))
101 exitval = 1;
102 success = 0;
102 } else if (mkdir(*argv, omode) < 0) {
103 warn("%s", *argv);
103 } else if (mkdir(*argv, omode) < 0) {
104 warn("%s", *argv);
104 exitval = 1;
105 success = 0;
105 }
106 }
107 if (!success)
108 exitval = 1;
106 /*
107 * The mkdir() and umask() calls both honor only the low
108 * nine bits, so if you try to set a mode including the
109 * sticky, setuid, setgid bits you lose them. Don't do
110 * this unless the user has specifically requested a mode,
111 * as chmod will (obviously) ignore the umask.
112 */
109 /*
110 * The mkdir() and umask() calls both honor only the low
111 * nine bits, so if you try to set a mode including the
112 * sticky, setuid, setgid bits you lose them. Don't do
113 * this unless the user has specifically requested a mode,
114 * as chmod will (obviously) ignore the umask.
115 */
113 if ((exitval == 0) &&
114 (mode != NULL) && (chmod(*argv, omode) == -1)) {
115 warn("chmod %s", *argv);
116 if (success && mode != NULL && chmod(*argv, omode) == -1) {
117 warn("%s", *argv);
116 exitval = 1;
117 }
118 }
119 exit(exitval);
120}
121
122int
123build(path, omode)

--- 73 unchanged lines hidden ---
118 exitval = 1;
119 }
120 }
121 exit(exitval);
122}
123
124int
125build(path, omode)

--- 73 unchanged lines hidden ---