aboutsummaryrefslogtreecommitdiff
path: root/mtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'mtab.c')
-rw-r--r--mtab.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/mtab.c b/mtab.c
index e855717ce..98e42a383 100644
--- a/mtab.c
+++ b/mtab.c
@@ -26,8 +26,14 @@ erase_mtab(const char * name)
26 FILE *mountTable = setmntent(mtab_file, "r"); 26 FILE *mountTable = setmntent(mtab_file, "r");
27 struct mntent * m; 27 struct mntent * m;
28 28
29 if ( mountTable == 0 29 /* Check if reading the mtab file failed */
30 && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) { 30 if ( mountTable == 0
31#if ! defined BB_FEATURE_USE_PROCFS
32 ) {
33#else
34 /* Bummer. fall back on trying the /proc filesystem */
35 && (mountTable = setmntent("/proc/mounts", "r")) == 0 ) {
36#endif
31 perror(mtab_file); 37 perror(mtab_file);
32 return; 38 return;
33 } 39 }
@@ -76,13 +82,14 @@ write_mtab(char* blockDevice, char* directory,
76 if ( length > 1 && directory[length - 1] == '/' ) 82 if ( length > 1 && directory[length - 1] == '/' )
77 directory[length - 1] = '\0'; 83 directory[length - 1] = '\0';
78 84
85#ifdef BB_FEATURE_USE_PROCFS
79 if ( filesystemType == 0 ) { 86 if ( filesystemType == 0 ) {
80 struct mntent * p 87 struct mntent *p = findMountPoint(blockDevice, "/proc/mounts");
81 = findMountPoint(blockDevice, "/proc/mounts");
82 88
83 if ( p && p->mnt_type ) 89 if ( p && p->mnt_type )
84 filesystemType = p->mnt_type; 90 filesystemType = p->mnt_type;
85 } 91 }
92#endif
86 m.mnt_fsname = blockDevice; 93 m.mnt_fsname = blockDevice;
87 m.mnt_dir = directory; 94 m.mnt_dir = directory;
88 m.mnt_type = filesystemType ? filesystemType : "default"; 95 m.mnt_type = filesystemType ? filesystemType : "default";