aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:01:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:01:53 +0000
commitfc56dd2e2128556971b9c0de329a2a6d15d5489f (patch)
tree0e20d6853819fdf2acdb388636db8f9709a3596c
parent8d474b50094b421c484abc528438357c0d70def7 (diff)
downloadbusybox-w32-fc56dd2e2128556971b9c0de329a2a6d15d5489f.tar.gz
busybox-w32-fc56dd2e2128556971b9c0de329a2a6d15d5489f.tar.bz2
busybox-w32-fc56dd2e2128556971b9c0de329a2a6d15d5489f.zip
mount: use bb_simplify_path as appropriate
-rw-r--r--util-linux/mount.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index bc9759e81..01b811471 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -234,43 +234,31 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
234 /* If the mount was successful, and we're maintaining an old-style 234 /* If the mount was successful, and we're maintaining an old-style
235 * mtab file by hand, add the new entry to it now. */ 235 * mtab file by hand, add the new entry to it now. */
236 236
237 if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) { 237 if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
238 char dirbuf[PATH_MAX]; 238 char *dir,*fsname;
239 char srcbuf[PATH_MAX];
240 FILE *mountTable = setmntent(bb_path_mtab_file, "a+"); 239 FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
241 int i; 240 int i;
242 241
243 if(!mountTable) 242 if (!mountTable)
244 bb_error_msg("no %s",bb_path_mtab_file); 243 bb_error_msg("no %s",bb_path_mtab_file);
245 244
246 // Add vfs string flags 245 // Add vfs string flags
247 246
248 for(i=0; mount_options[i].flags != MS_REMOUNT; i++) 247 for (i=0; mount_options[i].flags != MS_REMOUNT; i++)
249 if (mount_options[i].flags > 0 && (mount_options[i].flags & vfsflags)) 248 if (mount_options[i].flags > 0 && (mount_options[i].flags & vfsflags))
250 append_mount_options(&(mp->mnt_opts), mount_options[i].name); 249 append_mount_options(&(mp->mnt_opts), mount_options[i].name);
251 250
252 // Remove trailing / (if any) from directory we mounted on 251 // Remove trailing / (if any) from directory we mounted on
253 252
254 i = strlen(mp->mnt_dir) - 1; 253 i = strlen(mp->mnt_dir) - 1;
255 if(i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0; 254 if (i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0;
256 255
257 // Add full pathnames as needed 256 // Convert to canonical pathnames as needed
258 257
259 if (mp->mnt_dir[0] != '/') { 258 mp->mnt_dir = dir = bb_simplify_path(mp->mnt_dir);
260 getcwd(dirbuf, sizeof(dirbuf)); 259 fsname = 0;
261 i = strlen(dirbuf);
262 /* strcat() would be unsafe here */
263 snprintf(dirbuf+i, sizeof(dirbuf)-i, "/%s", mp->mnt_dir);
264 mp->mnt_dir = dirbuf;
265 }
266 if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */ 260 if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
267 if (mp->mnt_fsname[0] != '/') { 261 mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
268 getcwd(srcbuf, sizeof(srcbuf));
269 i = strlen(srcbuf);
270 snprintf(srcbuf+i, sizeof(srcbuf)-i, "/%s",
271 mp->mnt_fsname);
272 mp->mnt_fsname = srcbuf;
273 }
274 mp->mnt_type = "none"; 262 mp->mnt_type = "none";
275 } 263 }
276 mp->mnt_freq = mp->mnt_passno = 0; 264 mp->mnt_freq = mp->mnt_passno = 0;
@@ -279,6 +267,10 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
279 267
280 addmntent(mountTable, mp); 268 addmntent(mountTable, mp);
281 endmntent(mountTable); 269 endmntent(mountTable);
270 if (ENABLE_FEATURE_CLEAN_UP) {
271 free(dir);
272 free(fsname);
273 }
282 } 274 }
283 275
284 return rc; 276 return rc;