diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-14 13:19:19 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-14 13:19:19 +0000 |
commit | 727ef9444770bdd4f8253e96218ec1d5bc9888d3 (patch) | |
tree | 26fd5d048cebf8bfa0816e23341ec19abe40b47a /util-linux/mount.c | |
parent | 85c6de71bf23e991c8ae570e637839a59222496a (diff) | |
download | busybox-w32-727ef9444770bdd4f8253e96218ec1d5bc9888d3.tar.gz busybox-w32-727ef9444770bdd4f8253e96218ec1d5bc9888d3.tar.bz2 busybox-w32-727ef9444770bdd4f8253e96218ec1d5bc9888d3.zip |
mount: fix mtab support (but it is still rather buggy)
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r-- | util-linux/mount.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index bd2a62d64..4ed000e88 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -223,6 +223,8 @@ int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) | |||
223 | * mtab file by hand, add the new entry to it now. */ | 223 | * mtab file by hand, add the new entry to it now. */ |
224 | 224 | ||
225 | if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) { | 225 | if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) { |
226 | char dirbuf[PATH_MAX]; | ||
227 | char srcbuf[PATH_MAX]; | ||
226 | FILE *mountTable = setmntent(bb_path_mtab_file, "a+"); | 228 | FILE *mountTable = setmntent(bb_path_mtab_file, "a+"); |
227 | int i; | 229 | int i; |
228 | 230 | ||
@@ -232,27 +234,39 @@ int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) | |||
232 | // Add vfs string flags | 234 | // Add vfs string flags |
233 | 235 | ||
234 | for(i=0; mount_options[i].flags != MS_REMOUNT; i++) | 236 | for(i=0; mount_options[i].flags != MS_REMOUNT; i++) |
235 | if (mount_options[i].flags > 0) | 237 | if (mount_options[i].flags > 0 && (mount_options[i].flags&vfsflags)) |
236 | append_mount_options(&(mp->mnt_opts), mount_options[i].name); | 238 | append_mount_options(&(mp->mnt_opts), mount_options[i].name); |
237 | 239 | ||
238 | // Remove trailing / (if any) from directory we mounted on | 240 | // Remove trailing / (if any) from directory we mounted on |
239 | 241 | ||
240 | i = strlen(mp->mnt_dir); | 242 | i = strlen(mp->mnt_dir) - 1; |
241 | if(i>1 && mp->mnt_dir[i-1] == '/') mp->mnt_dir[i-1] = 0; | 243 | if(i > 0 && mp->mnt_dir[i] == '/') mp->mnt_dir[i] = 0; |
244 | |||
245 | // Add full pathnames as needed | ||
246 | |||
247 | if (mp->mnt_dir[0] != '/') { | ||
248 | getcwd(dirbuf, sizeof(dirbuf)); | ||
249 | i = strlen(dirbuf); | ||
250 | /* strcat() would be unsafe here */ | ||
251 | snprintf(dirbuf+i, sizeof(dirbuf)-i, "/%s", mp->mnt_dir); | ||
252 | mp->mnt_dir = dirbuf; | ||
253 | } | ||
254 | if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */ | ||
255 | if (mp->mnt_fsname[0] != '/') { | ||
256 | getcwd(srcbuf, sizeof(srcbuf)); | ||
257 | i = strlen(srcbuf); | ||
258 | snprintf(srcbuf+i, sizeof(srcbuf)-i, "/%s", | ||
259 | mp->mnt_fsname); | ||
260 | mp->mnt_fsname = srcbuf; | ||
261 | } | ||
262 | mp->mnt_type = "none"; | ||
263 | mp->mnt_freq = mp->mnt_passno = 0; | ||
264 | } | ||
242 | 265 | ||
243 | // Write and close. | 266 | // Write and close. |
244 | 267 | ||
245 | if(!mp->mnt_type || !*mp->mnt_type) mp->mnt_type="--bind"; | 268 | addmntent(mountTable, mp); |
246 | // addmntent(mountTable, mp); | ||
247 | if(0) bb_error_msg("buggy: addmntent(fsname='%s' dir='%s' type='%s' opts='%s')", | ||
248 | mp->mnt_fsname, | ||
249 | mp->mnt_dir, | ||
250 | mp->mnt_type, | ||
251 | mp->mnt_opts | ||
252 | ); | ||
253 | endmntent(mountTable); | 269 | endmntent(mountTable); |
254 | if (ENABLE_FEATURE_CLEAN_UP) | ||
255 | if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0; | ||
256 | } | 270 | } |
257 | 271 | ||
258 | return rc; | 272 | return rc; |