mirror of
https://github.com/sheumann/hush.git
synced 2025-01-06 21:30:08 +00:00
mount: use bb_simplify_path as appropriate
This commit is contained in:
parent
8d474b5009
commit
fc56dd2e21
@ -235,8 +235,7 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
|
|||||||
* mtab file by hand, add the new entry to it now. */
|
* mtab file by hand, add the new entry to it now. */
|
||||||
|
|
||||||
if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
|
if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
|
||||||
char dirbuf[PATH_MAX];
|
char *dir,*fsname;
|
||||||
char srcbuf[PATH_MAX];
|
|
||||||
FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
|
FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -254,23 +253,12 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
|
|||||||
i = strlen(mp->mnt_dir) - 1;
|
i = strlen(mp->mnt_dir) - 1;
|
||||||
if (i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
|
if (i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
|
||||||
|
|
||||||
// Add full pathnames as needed
|
// Convert to canonical pathnames as needed
|
||||||
|
|
||||||
if (mp->mnt_dir[0] != '/') {
|
mp->mnt_dir = dir = bb_simplify_path(mp->mnt_dir);
|
||||||
getcwd(dirbuf, sizeof(dirbuf));
|
fsname = 0;
|
||||||
i = strlen(dirbuf);
|
|
||||||
/* strcat() would be unsafe here */
|
|
||||||
snprintf(dirbuf+i, sizeof(dirbuf)-i, "/%s", mp->mnt_dir);
|
|
||||||
mp->mnt_dir = dirbuf;
|
|
||||||
}
|
|
||||||
if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
|
if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
|
||||||
if (mp->mnt_fsname[0] != '/') {
|
mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
|
||||||
getcwd(srcbuf, sizeof(srcbuf));
|
|
||||||
i = strlen(srcbuf);
|
|
||||||
snprintf(srcbuf+i, sizeof(srcbuf)-i, "/%s",
|
|
||||||
mp->mnt_fsname);
|
|
||||||
mp->mnt_fsname = srcbuf;
|
|
||||||
}
|
|
||||||
mp->mnt_type = "none";
|
mp->mnt_type = "none";
|
||||||
}
|
}
|
||||||
mp->mnt_freq = mp->mnt_passno = 0;
|
mp->mnt_freq = mp->mnt_passno = 0;
|
||||||
@ -279,6 +267,10 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
|
|||||||
|
|
||||||
addmntent(mountTable, mp);
|
addmntent(mountTable, mp);
|
||||||
endmntent(mountTable);
|
endmntent(mountTable);
|
||||||
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
|
free(dir);
|
||||||
|
free(fsname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user