diff options
Diffstat (limited to 'libbb/mtab.c')
-rw-r--r-- | libbb/mtab.c | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/libbb/mtab.c b/libbb/mtab.c index b1f74c476..fa4958c26 100644 --- a/libbb/mtab.c +++ b/libbb/mtab.c | |||
@@ -28,8 +28,8 @@ | |||
28 | #include "libbb.h" | 28 | #include "libbb.h" |
29 | 29 | ||
30 | #define MTAB_MAX_ENTRIES 40 | 30 | #define MTAB_MAX_ENTRIES 40 |
31 | static const int MS_RDONLY = 1; /* Mount read-only. */ | ||
32 | 31 | ||
32 | #ifdef CONFIG_FEATURE_MTAB_SUPPORT | ||
33 | void erase_mtab(const char *name) | 33 | void erase_mtab(const char *name) |
34 | { | 34 | { |
35 | struct mntent entries[MTAB_MAX_ENTRIES]; | 35 | struct mntent entries[MTAB_MAX_ENTRIES]; |
@@ -72,45 +72,4 @@ void erase_mtab(const char *name) | |||
72 | } else if (errno != EROFS) | 72 | } else if (errno != EROFS) |
73 | bb_perror_msg(bb_path_mtab_file); | 73 | bb_perror_msg(bb_path_mtab_file); |
74 | } | 74 | } |
75 | 75 | #endif | |
76 | void write_mtab(char *blockDevice, char *directory, | ||
77 | char *filesystemType, long flags, char *string_flags) | ||
78 | { | ||
79 | FILE *mountTable = setmntent(bb_path_mtab_file, "a+"); | ||
80 | struct mntent m; | ||
81 | |||
82 | if (mountTable == 0) { | ||
83 | bb_perror_msg(bb_path_mtab_file); | ||
84 | return; | ||
85 | } | ||
86 | if (mountTable) { | ||
87 | int length = strlen(directory); | ||
88 | |||
89 | if (length > 1 && directory[length - 1] == '/') | ||
90 | directory[length - 1] = '\0'; | ||
91 | |||
92 | if (filesystemType == 0) { | ||
93 | struct mntent *p = find_mount_point(blockDevice, "/proc/mounts"); | ||
94 | |||
95 | if (p && p->mnt_type) | ||
96 | filesystemType = p->mnt_type; | ||
97 | } | ||
98 | m.mnt_fsname = blockDevice; | ||
99 | m.mnt_dir = directory; | ||
100 | m.mnt_type = filesystemType ? filesystemType : "default"; | ||
101 | |||
102 | if (*string_flags) { | ||
103 | m.mnt_opts = string_flags; | ||
104 | } else { | ||
105 | if ((flags | MS_RDONLY) == flags) | ||
106 | m.mnt_opts = "ro"; | ||
107 | else | ||
108 | m.mnt_opts = "rw"; | ||
109 | } | ||
110 | |||
111 | m.mnt_freq = 0; | ||
112 | m.mnt_passno = 0; | ||
113 | addmntent(mountTable, &m); | ||
114 | endmntent(mountTable); | ||
115 | } | ||
116 | } | ||