diff options
| author | Jérémie Koenig <jk@jk.fr.eu.org> | 2010-03-26 19:08:53 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-26 19:08:53 +0100 |
| commit | fbedacfc8caa1ec8f14e664a881cb0a93c8f8712 (patch) | |
| tree | 6c08780bbaad6320149930bdbcfbee5a2eed9f5d /util-linux | |
| parent | 35fdb1bc9cb82fa5630c2d40ae49110ecd7c88ea (diff) | |
| download | busybox-w32-fbedacfc8caa1ec8f14e664a881cb0a93c8f8712.tar.gz busybox-w32-fbedacfc8caa1ec8f14e664a881cb0a93c8f8712.tar.bz2 busybox-w32-fbedacfc8caa1ec8f14e664a881cb0a93c8f8712.zip | |
Hurd compat fixes. Mostly dealing with absent PATH_MAX
Signed-off-by: Jérémie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/umount.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c index a4b2bd087..a19f86c3a 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c | |||
| @@ -39,6 +39,10 @@ | |||
| 39 | # define MS_RELATIME (1 << 21) | 39 | # define MS_RELATIME (1 << 21) |
| 40 | #endif | 40 | #endif |
| 41 | #include "libbb.h" | 41 | #include "libbb.h" |
| 42 | #ifndef PATH_MAX | ||
| 43 | # define PATH_MAX (4*1024) | ||
| 44 | #endif | ||
| 45 | |||
| 42 | 46 | ||
| 43 | #if defined(__dietlibc__) | 47 | #if defined(__dietlibc__) |
| 44 | /* 16.12.2006, Sampo Kellomaki (sampo@iki.fi) | 48 | /* 16.12.2006, Sampo Kellomaki (sampo@iki.fi) |
| @@ -69,7 +73,7 @@ int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
| 69 | int umount_main(int argc UNUSED_PARAM, char **argv) | 73 | int umount_main(int argc UNUSED_PARAM, char **argv) |
| 70 | { | 74 | { |
| 71 | int doForce; | 75 | int doForce; |
| 72 | char *const path = xmalloc(PATH_MAX + 2); /* to save stack */ | 76 | char *const buf = xmalloc(PATH_MAX * 2 + 128); /* to save stack */ |
| 73 | struct mntent me; | 77 | struct mntent me; |
| 74 | FILE *fp; | 78 | FILE *fp; |
| 75 | char *fstype = NULL; | 79 | char *fstype = NULL; |
| @@ -100,7 +104,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
| 100 | if (opt & OPT_ALL) | 104 | if (opt & OPT_ALL) |
| 101 | bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file); | 105 | bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file); |
| 102 | } else { | 106 | } else { |
| 103 | while (getmntent_r(fp, &me, path, PATH_MAX)) { | 107 | while (getmntent_r(fp, &me, buf, PATH_MAX * 2 + 128)) { |
| 104 | /* Match fstype if passed */ | 108 | /* Match fstype if passed */ |
| 105 | if (!match_fstype(&me, fstype)) | 109 | if (!match_fstype(&me, fstype)) |
| 106 | continue; | 110 | continue; |
| @@ -124,10 +128,11 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
| 124 | for (;;) { | 128 | for (;;) { |
| 125 | int curstat; | 129 | int curstat; |
| 126 | char *zapit = *argv; | 130 | char *zapit = *argv; |
| 131 | char *path; | ||
| 127 | 132 | ||
| 128 | // Do we already know what to umount this time through the loop? | 133 | // Do we already know what to umount this time through the loop? |
| 129 | if (m) | 134 | if (m) |
| 130 | safe_strncpy(path, m->dir, PATH_MAX); | 135 | path = xstrdup(m->dir); |
| 131 | // For umount -a, end of mtab means time to exit. | 136 | // For umount -a, end of mtab means time to exit. |
| 132 | else if (opt & OPT_ALL) | 137 | else if (opt & OPT_ALL) |
| 133 | break; | 138 | break; |
| @@ -136,10 +141,12 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
| 136 | if (!zapit) | 141 | if (!zapit) |
| 137 | break; | 142 | break; |
| 138 | argv++; | 143 | argv++; |
| 139 | realpath(zapit, path); | 144 | path = xmalloc_realpath(zapit); |
| 140 | for (m = mtl; m; m = m->next) | 145 | if (path) { |
| 141 | if (!strcmp(path, m->dir) || !strcmp(path, m->device)) | 146 | for (m = mtl; m; m = m->next) |
| 142 | break; | 147 | if (strcmp(path, m->dir) == 0 || strcmp(path, m->device) == 0) |
| 148 | break; | ||
| 149 | } | ||
| 143 | } | 150 | } |
| 144 | // If we couldn't find this sucker in /etc/mtab, punt by passing our | 151 | // If we couldn't find this sucker in /etc/mtab, punt by passing our |
| 145 | // command line argument straight to the umount syscall. Otherwise, | 152 | // command line argument straight to the umount syscall. Otherwise, |
| @@ -181,9 +188,13 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
| 181 | // Find next matching mtab entry for -a or umount /dev | 188 | // Find next matching mtab entry for -a or umount /dev |
| 182 | // Note this means that "umount /dev/blah" will unmount all instances | 189 | // Note this means that "umount /dev/blah" will unmount all instances |
| 183 | // of /dev/blah, not just the most recent. | 190 | // of /dev/blah, not just the most recent. |
| 184 | if (m) while ((m = m->next) != NULL) | 191 | if (m) { |
| 185 | if ((opt & OPT_ALL) || !strcmp(path, m->device)) | 192 | while ((m = m->next) != NULL) |
| 186 | break; | 193 | // NB: if m is non-NULL, path is non-NULL as well |
| 194 | if ((opt & OPT_ALL) || strcmp(path, m->device) == 0) | ||
| 195 | break; | ||
| 196 | } | ||
| 197 | free(path); | ||
| 187 | } | 198 | } |
| 188 | 199 | ||
| 189 | // Free mtab list if necessary | 200 | // Free mtab list if necessary |
| @@ -195,7 +206,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
| 195 | free(mtl); | 206 | free(mtl); |
| 196 | mtl = m; | 207 | mtl = m; |
| 197 | } | 208 | } |
| 198 | free(path); | 209 | free(buf); |
| 199 | } | 210 | } |
| 200 | 211 | ||
| 201 | return status; | 212 | return status; |
