Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/miscutils/makedevs.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/miscutils/makedevs.c
r821 r1770 8 8 */ 9 9 10 #include "busybox.h" 11 #include <stdio.h> 12 #include <stdlib.h> 13 #include <string.h> 14 #include <fcntl.h> 15 #include <time.h> 16 #include <ctype.h> 17 #include <unistd.h> 18 #include <sys/types.h> 19 #include <sys/sysmacros.h> /* major() and minor() */ 20 21 #ifdef CONFIG_FEATURE_MAKEDEVS_LEAF 10 #include "libbb.h" 11 12 #if ENABLE_FEATURE_MAKEDEVS_LEAF 13 int makedevs_main(int argc, char **argv); 22 14 int makedevs_main(int argc, char **argv) 23 15 { … … 31 23 basedev = argv[1]; 32 24 type = argv[2]; 33 Smajor = atoi(argv[3]);34 Sminor = atoi(argv[4]);35 S = atoi(argv[5]);36 E = atoi(argv[6]);25 Smajor = xatoi_u(argv[3]); 26 Sminor = xatoi_u(argv[4]); 27 S = xatoi_u(argv[5]); 28 E = xatoi_u(argv[6]); 37 29 nodname = argc == 8 ? basedev : buf; 38 30 … … 57 49 58 50 sz = snprintf(buf, sizeof(buf), "%s%d", basedev, S); 59 if (sz<0 || sz>=sizeof(buf)) /* libc different */51 if (sz < 0 || sz >= sizeof(buf)) /* libc different */ 60 52 bb_error_msg_and_die("%s too large", basedev); 61 53 … … 63 55 64 56 if (mknod(nodname, mode, makedev(Smajor, Sminor))) 65 bb_error_msg(" Failed to create: %s", nodname);57 bb_error_msg("failed to create: %s", nodname); 66 58 67 59 if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */ … … 74 66 } 75 67 76 #elif defined CONFIG_FEATURE_MAKEDEVS_TABLE68 #elif ENABLE_FEATURE_MAKEDEVS_TABLE 77 69 78 70 /* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ 79 71 72 int makedevs_main(int argc, char **argv); 80 73 int makedevs_main(int argc, char **argv) 81 74 { … … 86 79 int ret = EXIT_SUCCESS; 87 80 88 unsigned long flags; 89 flags = bb_getopt_ulflags(argc, argv, "d:", &line); 81 getopt32(argv, "d:", &line); 90 82 if (line) 91 table = bb_xfopen(line, "r");83 table = xfopen(line, "r"); 92 84 93 85 if (optind >= argc || (rootdir=argv[optind])==NULL) { … … 95 87 } 96 88 97 bb_xchdir(rootdir);89 xchdir(rootdir); 98 90 99 91 umask(0); … … 106 98 } 107 99 108 while ((line = bb_get_chomped_line_from_file(table))) {100 while ((line = xmalloc_getline(table))) { 109 101 char type; 110 102 unsigned int mode = 0755; … … 130 122 if (*line=='\0' || *line=='#' || isspace(*line)) 131 123 continue; 132 bb_error_msg("line %d invalid: '%s' \n", linenum, line);124 bb_error_msg("line %d invalid: '%s'", linenum, line); 133 125 ret = EXIT_FAILURE; 134 126 continue; … … 138 130 } 139 131 140 gid = (*group) ? get_ug_id(group, bb_xgetgrnam) : getgid();141 uid = (*user) ? get_ug_id(user, bb_xgetpwnam) : getuid();132 gid = (*group) ? get_ug_id(group, xgroup2gid) : getgid(); 133 uid = (*user) ? get_ug_id(user, xuname2uid) : getuid(); 142 134 full_name = concat_path_file(rootdir, name); 143 135 … … 171 163 goto loop; 172 164 } 173 } else 174 { 165 } else { 175 166 dev_t rdev; 176 167 … … 196 187 for (i = start; i < count; i++) { 197 188 sprintf(full_name_inc, "%s%d", full_name, i); 198 rdev = (major << 8) + minor + (i * increment - start);189 rdev = makedev(major, minor + (i * increment - start)); 199 190 if (mknod(full_name_inc, mode, rdev) == -1) { 200 bb_perror_msg("line %d: c ouldnot create node %s", linenum, full_name_inc);191 bb_perror_msg("line %d: cannot create node %s", linenum, full_name_inc); 201 192 ret = EXIT_FAILURE; 202 193 } … … 212 203 free(full_name_inc); 213 204 } else { 214 rdev = (major << 8) + minor;205 rdev = makedev(major, minor); 215 206 if (mknod(full_name, mode, rdev) == -1) { 216 bb_perror_msg("line %d: c ouldnot create node %s", linenum, full_name);207 bb_perror_msg("line %d: cannot create node %s", linenum, full_name); 217 208 ret = EXIT_FAILURE; 218 209 }
Note:
See TracChangeset
for help on using the changeset viewer.