aboutsummaryrefslogtreecommitdiff
path: root/libbb/find_mount_point.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/find_mount_point.c')
-rw-r--r--libbb/find_mount_point.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c
index 0e1be3820..cf06c6e18 100644
--- a/libbb/find_mount_point.c
+++ b/libbb/find_mount_point.c
@@ -6,6 +6,9 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9#if ENABLE_PLATFORM_MINGW32
10# define MNTENT_PRIVATE
11#endif
9#include "libbb.h" 12#include "libbb.h"
10#include <mntent.h> 13#include <mntent.h>
11 14
@@ -19,14 +22,22 @@
19struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) 22struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
20{ 23{
21 struct stat s; 24 struct stat s;
25#if !ENABLE_PLATFORM_MINGW32
22 FILE *mtab_fp; 26 FILE *mtab_fp;
23 struct mntent *mountEntry; 27 struct mntent *mountEntry;
24 dev_t devno_of_name; 28 dev_t devno_of_name;
25 bool block_dev; 29 bool block_dev;
30#else
31 struct mntent *mountEntry;
32 static struct mntdata *data = NULL;
33 char *current;
34 const char *path;
35#endif
26 36
27 if (stat(name, &s) != 0) 37 if (stat(name, &s) != 0)
28 return NULL; 38 return NULL;
29 39
40#if !ENABLE_PLATFORM_MINGW32
30 devno_of_name = s.st_dev; 41 devno_of_name = s.st_dev;
31 block_dev = 0; 42 block_dev = 0;
32 /* Why S_ISCHR? - UBI volumes use char devices, not block */ 43 /* Why S_ISCHR? - UBI volumes use char devices, not block */
@@ -74,6 +85,26 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
74 } 85 }
75 } 86 }
76 endmntent(mtab_fp); 87 endmntent(mtab_fp);
88#else
89 mountEntry = NULL;
90 path = NULL;
91 current = NULL;
92
93 if ( isalpha(name[0]) && name[1] == ':' ) {
94 path = name;
95 } else {
96 path = current = xrealloc_getcwd_or_warn(NULL);
97 }
98
99 if ( path && isalpha(path[0]) && path[1] == ':' ) {
100 if (data == NULL)
101 data = xmalloc(sizeof(*data));
102
103 fill_mntdata(data, toupper(path[0]) - 'A');
104 mountEntry = &data->me;
105 }
106 free(current);
107#endif
77 108
78 return mountEntry; 109 return mountEntry;
79} 110}