aboutsummaryrefslogtreecommitdiff
path: root/win32/mntent.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/mntent.c')
-rw-r--r--win32/mntent.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/win32/mntent.c b/win32/mntent.c
new file mode 100644
index 000000000..22efbf1b7
--- /dev/null
+++ b/win32/mntent.c
@@ -0,0 +1,59 @@
1/*
2 * A simple WIN32 implementation of mntent routines. It only handles
3 * fixed logical drives.
4 */
5#include "libbb.h"
6
7struct mntdata {
8 DWORD flags;
9 int index;
10};
11
12FILE *setmntent(const char *file, const char *mode)
13{
14 struct mntdata *data;
15
16 if ( (data=malloc(sizeof(struct mntdata))) == NULL ) {
17 return NULL;
18 }
19
20 data->flags = GetLogicalDrives();
21 data->index = -1;
22
23 return (FILE *)data;
24}
25
26struct mntent *getmntent(FILE *stream)
27{
28 struct mntdata *data = (struct mntdata *)stream;
29 static char mnt_fsname[4];
30 static char mnt_dir[4];
31 static struct mntent my_mount_entry = { mnt_fsname, mnt_dir, "", 0, 0 };
32 static struct mntent *entry;
33
34 entry = NULL;
35 while ( ++data->index < 26 ) {
36 if ( (data->flags & 1<<data->index) != 0 ) {
37 mnt_fsname[0] = 'A' + data->index;
38 mnt_fsname[1] = ':';
39 mnt_fsname[2] = '\0';
40 mnt_dir[0] = 'A' + data->index;
41 mnt_dir[1] = ':';
42 mnt_dir[2] = '\\';
43 mnt_dir[3] = '\0';
44
45 if ( GetDriveType(mnt_dir) == DRIVE_FIXED ) {
46 entry = &my_mount_entry;
47 break;
48 }
49 }
50 }
51
52 return entry;
53}
54
55int endmntent(FILE *stream)
56{
57 free(stream);
58 return 0;
59}