aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-06-27 13:40:07 +0100
committerRon Yorston <rmy@pobox.com>2021-06-27 14:05:33 +0100
commit0fdf99bee07b6c38795eb5415b5e337ab82cfba8 (patch)
tree09409cdc12b08bd3e37c942738525666ed759a02 /libbb
parent6d6856355aec9ed6c9b8039b9b1ec8f997395c9e (diff)
downloadbusybox-w32-0fdf99bee07b6c38795eb5415b5e337ab82cfba8.tar.gz
busybox-w32-0fdf99bee07b6c38795eb5415b5e337ab82cfba8.tar.bz2
busybox-w32-0fdf99bee07b6c38795eb5415b5e337ab82cfba8.zip
win32: changes to mntent implementation
Make the structure returned by getmntent(3) static so it persists after endmntent(3) closes the stream. No current caller in the WIN32 port needs this functionality but it's good to match the documented behaviour. Populate more fields of the mntent structure in find_mount_point(). This is required to support the df -t and -T flags recently added upstream. The static structures used here are allocated on demand. Separate static structures are used in each case because df iterates through mounts calling statfs(2) on each and the WIN32 implementation of statfs(2) calls find_mount_point().
Diffstat (limited to 'libbb')
-rw-r--r--libbb/find_mount_point.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c
index edf734614..2464357c1 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
@@ -25,13 +28,7 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
25 dev_t devno_of_name; 28 dev_t devno_of_name;
26 bool block_dev; 29 bool block_dev;
27#else 30#else
28 static char mnt_fsname[4]; 31 static struct mntdata *data = NULL;
29 static char mnt_dir[4];
30 static char mnt_type[1];
31 static char mnt_opts[1];
32 static struct mntent my_mount_entry = {
33 mnt_fsname, mnt_dir, mnt_type, mnt_opts, 0, 0
34 };
35 char *current; 32 char *current;
36 const char *path; 33 const char *path;
37 DWORD len; 34 DWORD len;
@@ -105,15 +102,11 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
105 } 102 }
106 103
107 if ( path && isalpha(path[0]) && path[1] == ':' ) { 104 if ( path && isalpha(path[0]) && path[1] == ':' ) {
108 mnt_fsname[0] = path[0]; 105 if (data == NULL)
109 mnt_fsname[1] = path[1]; 106 data = xmalloc(sizeof(*data));
110 mnt_fsname[2] = '\0';
111 mnt_dir[0] = path[0];
112 mnt_dir[1] = path[1];
113 mnt_dir[2] = '\\';
114 mnt_dir[3] = '\0';
115 107
116 mountEntry = &my_mount_entry; 108 fill_mntdata(data, toupper(path[0]) - 'A');
109 mountEntry = &data->me;
117 } 110 }
118 free(current); 111 free(current);
119#endif 112#endif