Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Bernhard Reutner-Fischer | d9cf7ac | 2006-04-12 18:39:58 +0000 | [diff] [blame] | 2 | /* |
| 3 | * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> |
| 4 | * |
| 5 | * makedevs |
| 6 | * Make ranges of device files quickly. |
| 7 | * known bugs: can't deal with alpha ranges |
| 8 | */ |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 9 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 10 | //usage:#if ENABLE_FEATURE_MAKEDEVS_LEAF |
| 11 | //usage:#define makedevs_trivial_usage |
| 12 | //usage: "NAME TYPE MAJOR MINOR FIRST LAST [s]" |
| 13 | //usage:#define makedevs_full_usage "\n\n" |
| 14 | //usage: "Create a range of block or character special files" |
| 15 | //usage: "\n" |
| 16 | //usage: "\nTYPE is:" |
| 17 | //usage: "\n b Block device" |
| 18 | //usage: "\n c Character device" |
| 19 | //usage: "\n f FIFO, MAJOR and MINOR are ignored" |
| 20 | //usage: "\n" |
| 21 | //usage: "\nFIRST..LAST specify numbers appended to NAME." |
| 22 | //usage: "\nIf 's' is the last argument, the base device is created as well." |
| 23 | //usage: "\n" |
| 24 | //usage: "\nExamples:" |
| 25 | //usage: "\n makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63" |
| 26 | //usage: "\n makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8" |
| 27 | //usage: |
| 28 | //usage:#define makedevs_example_usage |
| 29 | //usage: "# makedevs /dev/ttyS c 4 66 2 63\n" |
| 30 | //usage: "[creates ttyS2-ttyS63]\n" |
| 31 | //usage: "# makedevs /dev/hda b 3 0 0 8 s\n" |
| 32 | //usage: "[creates hda,hda1-hda8]\n" |
| 33 | //usage:#endif |
| 34 | //usage: |
| 35 | //usage:#if ENABLE_FEATURE_MAKEDEVS_TABLE |
| 36 | //usage:#define makedevs_trivial_usage |
| 37 | //usage: "[-d device_table] rootdir" |
| 38 | //usage:#define makedevs_full_usage "\n\n" |
| 39 | //usage: "Create a range of special files as specified in a device table.\n" |
| 40 | //usage: "Device table entries take the form of:\n" |
| 41 | //usage: "<type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n" |
| 42 | //usage: "Where name is the file name, type can be one of:\n" |
| 43 | //usage: " f Regular file\n" |
| 44 | //usage: " d Directory\n" |
| 45 | //usage: " c Character device\n" |
| 46 | //usage: " b Block device\n" |
| 47 | //usage: " p Fifo (named pipe)\n" |
| 48 | //usage: "uid is the user id for the target file, gid is the group id for the\n" |
| 49 | //usage: "target file. The rest of the entries (major, minor, etc) apply to\n" |
| 50 | //usage: "to device special files. A '-' may be used for blank entries." |
| 51 | //usage: |
| 52 | //usage:#define makedevs_example_usage |
| 53 | //usage: "For example:\n" |
| 54 | //usage: "<name> <type> <mode><uid><gid><major><minor><start><inc><count>\n" |
| 55 | //usage: "/dev d 755 0 0 - - - - -\n" |
| 56 | //usage: "/dev/console c 666 0 0 5 1 - - -\n" |
| 57 | //usage: "/dev/null c 666 0 0 1 3 0 0 -\n" |
| 58 | //usage: "/dev/zero c 666 0 0 1 5 0 0 -\n" |
| 59 | //usage: "/dev/hda b 640 0 0 3 0 0 0 -\n" |
| 60 | //usage: "/dev/hda b 640 0 0 3 1 1 1 15\n\n" |
| 61 | //usage: "Will Produce:\n" |
| 62 | //usage: "/dev\n" |
| 63 | //usage: "/dev/console\n" |
| 64 | //usage: "/dev/null\n" |
| 65 | //usage: "/dev/zero\n" |
| 66 | //usage: "/dev/hda\n" |
| 67 | //usage: "/dev/hda[0-15]\n" |
| 68 | //usage:#endif |
| 69 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 70 | #include "libbb.h" |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 71 | |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 72 | #if ENABLE_FEATURE_MAKEDEVS_LEAF |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 73 | /* |
| 74 | makedevs NAME TYPE MAJOR MINOR FIRST LAST [s] |
| 75 | TYPEs: |
| 76 | b Block device |
| 77 | c Character device |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 78 | f FIFO |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 79 | |
| 80 | FIRST..LAST specify numbers appended to NAME. |
| 81 | If 's' is the last argument, the base device is created as well. |
| 82 | Examples: |
| 83 | makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63 |
| 84 | makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8 |
| 85 | */ |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 86 | int makedevs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 87 | int makedevs_main(int argc, char **argv) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 88 | { |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 89 | mode_t mode; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 90 | char *basedev, *type, *nodname, *buf; |
Eric Andersen | 4f807a8 | 2004-07-26 09:11:12 +0000 | [diff] [blame] | 91 | int Smajor, Sminor, S, E; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 92 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 93 | if (argc < 7 || argv[1][0] == '-') |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 94 | bb_show_usage(); |
Erik Andersen | 5e1189e | 2000-04-15 16:34:54 +0000 | [diff] [blame] | 95 | |
Eric Andersen | 19732c6 | 2002-04-13 14:26:44 +0000 | [diff] [blame] | 96 | basedev = argv[1]; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 97 | buf = xasprintf("%s%u", argv[1], (unsigned)-1); |
Eric Andersen | 19732c6 | 2002-04-13 14:26:44 +0000 | [diff] [blame] | 98 | type = argv[2]; |
Denys Vlasenko | 7783248 | 2010-08-12 14:14:45 +0200 | [diff] [blame] | 99 | Smajor = xatoi_positive(argv[3]); |
| 100 | Sminor = xatoi_positive(argv[4]); |
| 101 | S = xatoi_positive(argv[5]); |
| 102 | E = xatoi_positive(argv[6]); |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 103 | nodname = argv[7] ? basedev : buf; |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 104 | |
| 105 | mode = 0660; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 106 | switch (type[0]) { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 107 | case 'c': |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 108 | mode |= S_IFCHR; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 109 | break; |
| 110 | case 'b': |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 111 | mode |= S_IFBLK; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 112 | break; |
| 113 | case 'f': |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 114 | mode |= S_IFIFO; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 115 | break; |
| 116 | default: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 117 | bb_show_usage(); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 118 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 119 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 120 | while (S <= E) { |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 121 | sprintf(buf, "%s%u", basedev, S); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 122 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 123 | /* if mode != S_IFCHR and != S_IFBLK, |
| 124 | * third param in mknod() ignored */ |
Eric Andersen | e71e760 | 2004-07-30 14:36:37 +0000 | [diff] [blame] | 125 | if (mknod(nodname, mode, makedev(Smajor, Sminor))) |
Denys Vlasenko | 651a269 | 2010-03-23 16:25:17 +0100 | [diff] [blame] | 126 | bb_perror_msg("can't create '%s'", nodname); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 127 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 128 | /*if (nodname == basedev)*/ /* ex. /dev/hda - to /dev/hda1 ... */ |
Eric Andersen | 3600602 | 2002-06-08 12:44:17 +0000 | [diff] [blame] | 129 | nodname = buf; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 130 | S++; |
| 131 | Sminor++; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 134 | return 0; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 137 | #elif ENABLE_FEATURE_MAKEDEVS_TABLE |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 138 | |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 139 | /* Licensed under GPLv2 or later, see file LICENSE in this source tree. */ |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 140 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 141 | int makedevs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 142 | int makedevs_main(int argc UNUSED_PARAM, char **argv) |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 143 | { |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 144 | parser_t *parser; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 145 | char *line = (char *)"-"; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 146 | int ret = EXIT_SUCCESS; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 147 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 148 | opt_complementary = "=1"; /* exactly one param */ |
Denis Vlasenko | fe7cd64 | 2007-08-18 15:32:12 +0000 | [diff] [blame] | 149 | getopt32(argv, "d:", &line); |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 150 | argv += optind; |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 151 | |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 152 | xchdir(*argv); /* ensure root dir exists */ |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 153 | |
| 154 | umask(0); |
| 155 | |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 156 | printf("rootdir=%s\ntable=", *argv); |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 157 | if (NOT_LONE_DASH(line)) { |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 158 | printf("'%s'\n", line); |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 159 | } else { |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 160 | puts("<stdin>"); |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 163 | parser = config_open(line); |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 164 | while (config_read(parser, &line, 1, 1, "# \t", PARSE_NORMAL)) { |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 165 | int linenum; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 166 | char type; |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 167 | unsigned mode = 0755; |
| 168 | unsigned major = 0; |
| 169 | unsigned minor = 0; |
| 170 | unsigned count = 0; |
| 171 | unsigned increment = 0; |
| 172 | unsigned start = 0; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 173 | char name[41]; |
| 174 | char user[41]; |
| 175 | char group[41]; |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 176 | char *full_name = name; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 177 | uid_t uid; |
| 178 | gid_t gid; |
| 179 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 180 | linenum = parser->lineno; |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 181 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 182 | if ((2 > sscanf(line, "%40s %c %o %40s %40s %u %u %u %u %u", |
| 183 | name, &type, &mode, user, group, |
Denys Vlasenko | e4dcba1 | 2010-10-28 18:57:19 +0200 | [diff] [blame] | 184 | &major, &minor, &start, &increment, &count)) |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 185 | || ((unsigned)(major | minor | start | count | increment) > 255) |
| 186 | ) { |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 187 | bb_error_msg("invalid line %d: '%s'", linenum, line); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 188 | ret = EXIT_FAILURE; |
| 189 | continue; |
| 190 | } |
Bernhard Reutner-Fischer | 1732974 | 2005-12-21 15:07:30 +0000 | [diff] [blame] | 191 | |
Denis Vlasenko | 9a44c4f | 2006-12-28 05:44:47 +0000 | [diff] [blame] | 192 | gid = (*group) ? get_ug_id(group, xgroup2gid) : getgid(); |
| 193 | uid = (*user) ? get_ug_id(user, xuname2uid) : getuid(); |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 194 | /* We are already in the right root dir, |
| 195 | * so make absolute paths relative */ |
| 196 | if ('/' == *full_name) |
| 197 | full_name++; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 198 | |
| 199 | if (type == 'd') { |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 200 | bb_make_directory(full_name, mode | S_IFDIR, FILEUTILS_RECUR); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 201 | if (chown(full_name, uid, gid) == -1) { |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 202 | chown_fail: |
| 203 | bb_perror_msg("line %d: can't chown %s", linenum, full_name); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 204 | ret = EXIT_FAILURE; |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 205 | continue; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 206 | } |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 207 | if (chmod(full_name, mode) < 0) { |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 208 | chmod_fail: |
| 209 | bb_perror_msg("line %d: can't chmod %s", linenum, full_name); |
Eric Andersen | 90161c9 | 2005-07-18 22:40:59 +0000 | [diff] [blame] | 210 | ret = EXIT_FAILURE; |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 211 | continue; |
Eric Andersen | 90161c9 | 2005-07-18 22:40:59 +0000 | [diff] [blame] | 212 | } |
| 213 | } else if (type == 'f') { |
| 214 | struct stat st; |
| 215 | if ((stat(full_name, &st) < 0 || !S_ISREG(st.st_mode))) { |
| 216 | bb_perror_msg("line %d: regular file '%s' does not exist", linenum, full_name); |
| 217 | ret = EXIT_FAILURE; |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 218 | continue; |
Eric Andersen | 90161c9 | 2005-07-18 22:40:59 +0000 | [diff] [blame] | 219 | } |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 220 | if (chown(full_name, uid, gid) < 0) |
| 221 | goto chown_fail; |
| 222 | if (chmod(full_name, mode) < 0) |
| 223 | goto chmod_fail; |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 224 | } else { |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 225 | dev_t rdev; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 226 | unsigned i; |
| 227 | char *full_name_inc; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 228 | |
| 229 | if (type == 'p') { |
| 230 | mode |= S_IFIFO; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 231 | } else if (type == 'c') { |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 232 | mode |= S_IFCHR; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 233 | } else if (type == 'b') { |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 234 | mode |= S_IFBLK; |
| 235 | } else { |
Eric Andersen | 2ada89b | 2005-07-18 09:45:35 +0000 | [diff] [blame] | 236 | bb_error_msg("line %d: unsupported file type %c", linenum, type); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 237 | ret = EXIT_FAILURE; |
Denis Vlasenko | b2dc913 | 2008-08-03 22:14:02 +0000 | [diff] [blame] | 238 | continue; |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 241 | full_name_inc = xmalloc(strlen(full_name) + sizeof(int)*3 + 2); |
| 242 | if (count) |
| 243 | count--; |
| 244 | for (i = start; i <= start + count; i++) { |
| 245 | sprintf(full_name_inc, count ? "%s%u" : "%s", full_name, i); |
| 246 | rdev = makedev(major, minor + (i - start) * increment); |
| 247 | if (mknod(full_name_inc, mode, rdev) < 0) { |
| 248 | bb_perror_msg("line %d: can't create node %s", linenum, full_name_inc); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 249 | ret = EXIT_FAILURE; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 250 | } else if (chown(full_name_inc, uid, gid) < 0) { |
| 251 | bb_perror_msg("line %d: can't chown %s", linenum, full_name_inc); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 252 | ret = EXIT_FAILURE; |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 253 | } else if (chmod(full_name_inc, mode) < 0) { |
| 254 | bb_perror_msg("line %d: can't chmod %s", linenum, full_name_inc); |
Eric Andersen | 90161c9 | 2005-07-18 22:40:59 +0000 | [diff] [blame] | 255 | ret = EXIT_FAILURE; |
| 256 | } |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 257 | } |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 258 | free(full_name_inc); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 259 | } |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 260 | } |
Denis Vlasenko | e1fa817 | 2008-08-01 02:15:05 +0000 | [diff] [blame] | 261 | if (ENABLE_FEATURE_CLEAN_UP) |
| 262 | config_close(parser); |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 263 | |
Bernhard Reutner-Fischer | 56fbd21 | 2006-04-24 17:41:29 +0000 | [diff] [blame] | 264 | return ret; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 265 | } |
Eric Andersen | e8614db | 2005-07-18 09:28:36 +0000 | [diff] [blame] | 266 | |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 267 | #else |
Bernhard Reutner-Fischer | 771b186 | 2006-03-24 14:30:05 +0000 | [diff] [blame] | 268 | # error makedevs configuration error, either leaf or table must be selected |
Eric Andersen | 3d92562 | 2005-06-09 10:16:02 +0000 | [diff] [blame] | 269 | #endif |