Changeset 77739 in vbox for trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
- Timestamp:
- Mar 17, 2019 1:46:38 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
r77534 r77739 378 378 int c; 379 379 int err; 380 int saved_errno; 380 381 int nomtab = 0; 381 382 unsigned long flags = MS_NODEV; … … 497 498 */ 498 499 err = mount(host_name, mount_point, "vboxsf", flags, &mntinf); 499 if (err == -1 && errno == EPROTO) 500 { 501 /* Sometimes the mount utility messes up the share name. Try to 502 * un-mangle it again. */ 500 saved_errno = errno; 501 502 /* Some versions of the mount utility (unknown which, if any) will turn the 503 shared folder name into an absolute path. So, we check if it starts with 504 the CWD and removes it. We must do this after failing, because there is 505 not actual restrictions on the shared folder name wrt to slashes and such. */ 506 if (err == -1 && errno == ENXIO && host_name[0] == '/') 507 { 503 508 char szCWD[4096]; 504 size_t cchCWD; 505 if (!getcwd(szCWD, sizeof(szCWD))) 506 panic_err("%s: failed to get the current working directory", argv[0]); 507 cchCWD = strlen(szCWD); 508 if (!strncmp(host_name, szCWD, cchCWD)) 509 { 510 while (host_name[cchCWD] == '/') 511 ++cchCWD; 512 /* We checked before that we have enough space */ 513 strcpy(mntinf.name, host_name + cchCWD); 514 } 515 err = mount(host_name, mount_point, "vboxsf", flags, &mntinf); 509 if (getcwd(szCWD, sizeof(szCWD)) != NULL) 510 { 511 size_t cchCWD = strlen(szCWD); 512 if (!strncmp(host_name, szCWD, cchCWD)) 513 { 514 while (host_name[cchCWD] == '/') 515 ++cchCWD; 516 if (host_name[cchCWD]) 517 { 518 /* We checked before that we have enough space. */ 519 strcpy(mntinf.name, host_name + cchCWD); 520 err = mount(host_name, mount_point, "vboxsf", flags, &mntinf); 521 saved_errno = errno; 522 } 523 } 524 } 525 else 526 fprintf(stderr, "%s: failed to get the current working directory: %s", argv[0], strerror(errno)); 527 errno = saved_errno; 516 528 } 517 529 if (err) 518 panic_err("%s: mounting failed with the error", argv[0]); 530 { 531 if (saved_errno == ENXIO) 532 panic("%s: shared folder '%s' was not found (check VM settings / spelling)\n", argv[0], host_name); 533 else 534 panic_err("%s: mounting failed with the error", argv[0]); 535 } 519 536 520 537 if (!nomtab)
Note:
See TracChangeset
for help on using the changeset viewer.