aboutsummaryrefslogtreecommitdiff
path: root/miscutils/makedevs.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-10-28 09:24:33 +0000
committerRob Landley <rob@landley.net>2005-10-28 09:24:33 +0000
commit1b751c894b520846af8575d09187ce342e88778c (patch)
treeea1bfb15742becbaab52960ee9fad82aba9fbcee /miscutils/makedevs.c
parent0f34a821ab99e4936c7aa4974f58784442172211 (diff)
downloadbusybox-w32-1b751c894b520846af8575d09187ce342e88778c.tar.gz
busybox-w32-1b751c894b520846af8575d09187ce342e88778c.tar.bz2
busybox-w32-1b751c894b520846af8575d09187ce342e88778c.zip
Rob Sullivan sent in some cleanups, which I beat on slightly.
Diffstat (limited to 'miscutils/makedevs.c')
-rw-r--r--miscutils/makedevs.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index e988400eb..7bfe54fc1 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -4,7 +4,6 @@
4#include <stdlib.h> 4#include <stdlib.h>
5#include <string.h> 5#include <string.h>
6#include <fcntl.h> 6#include <fcntl.h>
7#include <getopt.h>
8#include <time.h> 7#include <time.h>
9#include <ctype.h> 8#include <ctype.h>
10#include <unistd.h> 9#include <unistd.h>
@@ -76,40 +75,20 @@ int makedevs_main(int argc, char **argv)
76 75
77#elif defined CONFIG_FEATURE_MAKEDEVS_TABLE 76#elif defined CONFIG_FEATURE_MAKEDEVS_TABLE
78 77
79/* 78/* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */
80 * This program is free software; you can redistribute it and/or modify
81 * it under the terms of the GNU General Public License version 2 as
82 * published by the Free Software Foundation.
83 *
84 * This program is distributed in the hope that it will be useful,
85 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 * GNU Library General Public License for more details.
88 *
89 * You should have received a copy of the GNU General Public License
90 * along with this program; if not, write to the Free Software
91 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
92 *
93 */
94 79
95extern int makedevs_main(int argc, char **argv) 80extern int makedevs_main(int argc, char **argv)
96{ 81{
97 int opt;
98 FILE *table = stdin; 82 FILE *table = stdin;
99 char *rootdir = NULL; 83 char *rootdir = NULL;
100 char *line = NULL; 84 char *line = NULL;
101 int linenum = 0; 85 int linenum = 0;
102 int ret = EXIT_SUCCESS; 86 int ret = EXIT_SUCCESS;
103 87
104 while ((opt = getopt(argc, argv, "d:")) != -1) { 88 unsigned long flags;
105 switch(opt) { 89 flags = bb_getopt_ulflags(argc, argv, "d:", &line);
106 case 'd': 90 if (line)
107 table = bb_xfopen((line=optarg), "r"); 91 table = bb_xfopen(line, "r");
108 break;
109 default:
110 bb_show_usage();
111 }
112 }
113 92
114 if (optind >= argc || (rootdir=argv[optind])==NULL) { 93 if (optind >= argc || (rootdir=argv[optind])==NULL) {
115 bb_error_msg_and_die("root directory not specified"); 94 bb_error_msg_and_die("root directory not specified");
@@ -159,16 +138,9 @@ extern int makedevs_main(int argc, char **argv)
159 if (name[0] == '#') { 138 if (name[0] == '#') {
160 continue; 139 continue;
161 } 140 }
162 if (group) { 141
163 gid = get_ug_id(group, bb_xgetgrnam); 142 gid = group ? get_ug_id(group, bb_xgetgrnam) : getgid();
164 } else { 143 uid = user ? get_ug_id(user, bb_xgetpwnam) : getuid();
165 gid = getgid();
166 }
167 if (user) {
168 uid = get_ug_id(user, bb_xgetpwnam);
169 } else {
170 uid = getuid();
171 }
172 full_name = concat_path_file(rootdir, name); 144 full_name = concat_path_file(rootdir, name);
173 145
174 if (type == 'd') { 146 if (type == 'd') {