Commit 79e32503 authored by Eric Andersen's avatar Eric Andersen
Browse files

minor cleanups

parent 93e6e073
Loading
Loading
Loading
Loading
+54 −45
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ void bb_error_msg_and_die(const char *s, ...)
	putc('\n', stderr);
	exit(1);
}

void bb_vperror_msg(const char *s, va_list p)
{
	int err=errno;
@@ -321,25 +322,8 @@ char *concat_path_file(const char *path, const char *filename)
	return outbuf;
}

int main(int argc, char **argv)
void bb_show_usage(void)
{
	int opt;
	FILE *table = stdin;
	char *rootdir = "./";
	char *line;
	int linenum = 0;
	int ret = EXIT_SUCCESS;

	bb_applet_name = basename(argv[0]);
	argc--;
	argv++;

	while ((opt = getopt(argc, argv, "d:")) != -1) {
		switch(opt) {
		case 'd':
			table = bb_xfopen(optarg, "r");
			break;
		default:
	fprintf(stderr, "%s: [-d device_table] rootdir\n\n", bb_applet_name);
	fprintf(stderr, "Creates a batch of special files as specified in a device table.\n");
	fprintf(stderr, "Device table entries take the form of:\n");
@@ -370,13 +354,31 @@ int main(int argc, char **argv)
	fprintf(stderr, "/dev/hda[0-15]\n");
	exit(1);
}

int main(int argc, char **argv)
{
	int opt;
	FILE *table = stdin;
	char *rootdir = NULL;
	char *line = NULL;
	int linenum = 0;
	int ret = EXIT_SUCCESS;

	bb_applet_name = basename(argv[0]);

	while ((opt = getopt(argc, argv, "d:")) != -1) {
		switch(opt) {
			case 'd':
				table = bb_xfopen((line=optarg), "r");
				break;
			default:
				bb_show_usage();
		}
	}

	if (optind >= argc) {
	if (optind >= argc || (rootdir=argv[optind])==NULL) {
		bb_error_msg_and_die("root directory not speficied");
	}
	rootdir = argv[optind];


	if (chdir(rootdir) != 0) {
		bb_perror_msg_and_die("Couldnt chdir to %s", rootdir);
@@ -384,6 +386,13 @@ int main(int argc, char **argv)

	umask(0);

	printf("rootdir=%s\n", rootdir);
	if (line) {
		printf("table='%s'\n", line);
	} else {
		printf("table=<stdin>\n");
	}

	while ((line = bb_get_chomped_line_from_file(table))) {
		char type;
		unsigned int mode = 0755;