aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-05-07 01:38:03 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-05-07 01:38:03 +0000
commit3aae10014c184cb28e30196cafa143fe622fc508 (patch)
treefeb98587b0ca90a02751561132777eed4f2b91b4
parent2e6c87876353cf5e038d8430c076f645be51da75 (diff)
downloadbusybox-w32-3aae10014c184cb28e30196cafa143fe622fc508.tar.gz
busybox-w32-3aae10014c184cb28e30196cafa143fe622fc508.tar.bz2
busybox-w32-3aae10014c184cb28e30196cafa143fe622fc508.zip
Device may not be a real filename
-rw-r--r--mount.c26
-rw-r--r--util-linux/mount.c26
2 files changed, 32 insertions, 20 deletions
diff --git a/mount.c b/mount.c
index 9d61bd3e3..fa885cb1e 100644
--- a/mount.c
+++ b/mount.c
@@ -334,12 +334,14 @@ void show_mounts()
334 334
335extern int mount_main(int argc, char **argv) 335extern int mount_main(int argc, char **argv)
336{ 336{
337 struct stat statbuf;
337 char string_flags_buf[1024] = ""; 338 char string_flags_buf[1024] = "";
338 char *string_flags = string_flags_buf; 339 char *string_flags = string_flags_buf;
339 char *extra_opts = string_flags_buf; 340 char *extra_opts = string_flags_buf;
340 int flags = 0; 341 int flags = 0;
341 char *filesystemType = "auto"; 342 char *filesystemType = "auto";
342 char device[PATH_MAX], directory[PATH_MAX]; 343 char *device = xmalloc(PATH_MAX);
344 char *directory = xmalloc(PATH_MAX);
343 int all = FALSE; 345 int all = FALSE;
344 int fakeIt = FALSE; 346 int fakeIt = FALSE;
345 int useMtab = TRUE; 347 int useMtab = TRUE;
@@ -382,19 +384,23 @@ extern int mount_main(int argc, char **argv)
382 show_mounts(); 384 show_mounts();
383 385
384 if (optind < argc) { 386 if (optind < argc) {
385 /* Don't canonicalize NFS devices. */ 387 /* if device is a filename get its real path */
386 if (strchr(argv[optind], ':') != NULL) 388 if ((strchr(argv[optind], ':') == NULL) &&
389 (stat(argv[optind], &statbuf) == 0)) {
390 realpath(argv[optind], device);
391 } else {
387 safe_strncpy(device, argv[optind], PATH_MAX); 392 safe_strncpy(device, argv[optind], PATH_MAX);
388 else if (realpath(argv[optind], device) == NULL) 393 }
389 perror_msg_and_die("%s", device);
390 } 394 }
391 395
392 if (optind + 1 < argc) 396 if (optind + 1 < argc) {
393 if (realpath(argv[optind + 1], directory) == NULL) 397 if (realpath(argv[optind + 1], directory) == NULL) {
394 perror_msg_and_die("%s", directory); 398 perror_msg_and_die("Invalid directory %s", directory);
395 399 }
400 }
401
396 if (all == TRUE || optind + 1 == argc) { 402 if (all == TRUE || optind + 1 == argc) {
397 struct mntent *m; 403 struct mntent *m = NULL;
398 FILE *f = setmntent("/etc/fstab", "r"); 404 FILE *f = setmntent("/etc/fstab", "r");
399 fstabmount = TRUE; 405 fstabmount = TRUE;
400 406
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 9d61bd3e3..fa885cb1e 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -334,12 +334,14 @@ void show_mounts()
334 334
335extern int mount_main(int argc, char **argv) 335extern int mount_main(int argc, char **argv)
336{ 336{
337 struct stat statbuf;
337 char string_flags_buf[1024] = ""; 338 char string_flags_buf[1024] = "";
338 char *string_flags = string_flags_buf; 339 char *string_flags = string_flags_buf;
339 char *extra_opts = string_flags_buf; 340 char *extra_opts = string_flags_buf;
340 int flags = 0; 341 int flags = 0;
341 char *filesystemType = "auto"; 342 char *filesystemType = "auto";
342 char device[PATH_MAX], directory[PATH_MAX]; 343 char *device = xmalloc(PATH_MAX);
344 char *directory = xmalloc(PATH_MAX);
343 int all = FALSE; 345 int all = FALSE;
344 int fakeIt = FALSE; 346 int fakeIt = FALSE;
345 int useMtab = TRUE; 347 int useMtab = TRUE;
@@ -382,19 +384,23 @@ extern int mount_main(int argc, char **argv)
382 show_mounts(); 384 show_mounts();
383 385
384 if (optind < argc) { 386 if (optind < argc) {
385 /* Don't canonicalize NFS devices. */ 387 /* if device is a filename get its real path */
386 if (strchr(argv[optind], ':') != NULL) 388 if ((strchr(argv[optind], ':') == NULL) &&
389 (stat(argv[optind], &statbuf) == 0)) {
390 realpath(argv[optind], device);
391 } else {
387 safe_strncpy(device, argv[optind], PATH_MAX); 392 safe_strncpy(device, argv[optind], PATH_MAX);
388 else if (realpath(argv[optind], device) == NULL) 393 }
389 perror_msg_and_die("%s", device);
390 } 394 }
391 395
392 if (optind + 1 < argc) 396 if (optind + 1 < argc) {
393 if (realpath(argv[optind + 1], directory) == NULL) 397 if (realpath(argv[optind + 1], directory) == NULL) {
394 perror_msg_and_die("%s", directory); 398 perror_msg_and_die("Invalid directory %s", directory);
395 399 }
400 }
401
396 if (all == TRUE || optind + 1 == argc) { 402 if (all == TRUE || optind + 1 == argc) {
397 struct mntent *m; 403 struct mntent *m = NULL;
398 FILE *f = setmntent("/etc/fstab", "r"); 404 FILE *f = setmntent("/etc/fstab", "r");
399 fstabmount = TRUE; 405 fstabmount = TRUE;
400 406