diff options
| author | Ron Yorston <rmy@pobox.com> | 2026-06-15 11:44:01 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2026-06-15 12:42:36 +0100 |
| commit | c5ff19688135ff077190a46de17f6cd7c005d1fc (patch) | |
| tree | ed01160fe82bfe89596a34f7b55e5a5a969b4157 /shell | |
| parent | 1313ab2691128c2255ac1ccdeea7021dbb9b4fe4 (diff) | |
| download | busybox-w32-c5ff19688135ff077190a46de17f6cd7c005d1fc.tar.gz busybox-w32-c5ff19688135ff077190a46de17f6cd7c005d1fc.tar.bz2 busybox-w32-c5ff19688135ff077190a46de17f6cd7c005d1fc.zip | |
ash: scan drives directly for 'pwd -a'
The shell builtin 'pwd' takes a Windows-specific '-a' option to
display the current directory on each drive.
Use Windows APIs directly to scan for valid drives instead of
'getmntent()'. Future changes will result in 'getmntent()'
returning mounted volumes as well as drives.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/shell/ash.c b/shell/ash.c index adde31ced..1f73592c4 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -11873,18 +11873,16 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 11873 | static void | 11873 | static void |
| 11874 | print_all_cwd(void) | 11874 | print_all_cwd(void) |
| 11875 | { | 11875 | { |
| 11876 | FILE *mnt; | 11876 | DWORD drives = GetLogicalDrives(); |
| 11877 | struct mntent *entry; | 11877 | char drive[3] = "A:"; |
| 11878 | char buffer[PATH_MAX]; | 11878 | char buffer[PATH_MAX]; |
| 11879 | 11879 | ||
| 11880 | mnt = setmntent(bb_path_mtab_file, "r"); | 11880 | for (int i = 0; i < 26; ++i) { |
| 11881 | if (mnt) { | 11881 | if ((drives & 1 << i) != 0) { |
| 11882 | while ((entry=getmntent(mnt)) != NULL) { | 11882 | drive[0] = 'A' + i; |
| 11883 | entry->mnt_dir[2] = '\0'; | 11883 | if (get_drive_cwd(drive, buffer, PATH_MAX) != NULL) |
| 11884 | if (get_drive_cwd(entry->mnt_dir, buffer, PATH_MAX) != NULL) | ||
| 11885 | out1fmt("%s\n", buffer); | 11884 | out1fmt("%s\n", buffer); |
| 11886 | } | 11885 | } |
| 11887 | endmntent(mnt); | ||
| 11888 | } | 11886 | } |
| 11889 | } | 11887 | } |
| 11890 | #endif | 11888 | #endif |
