tenox7 / lsblk Goto Github PK
View Code? Open in Web Editor NEWlsblk like utility for Windows
License: Apache License 2.0
lsblk like utility for Windows
License: Apache License 2.0
First thank you for this awesome tool. It runs fine on Windows PE without any optional component (WMI, .NET, etc).
I have found a minor issue. lsblk.exe -d
(X:
is Windows PE's ramdrive):
Volumes:
* \\?\Volume{b05dfcb2-e35d-49d8-96ef-9c144eb2ddf5}\
\GLOBAL??\Volume{b05dfcb2-e35d-49d8-96ef-9c144eb2ddf5}
Extent: disk=0 start=1048576 len=524288000
n=1 d=PhysicalDrive0 f=FAT32 p=
* \\?\Volume{d9b257fc-684e-4dcb-ab79-03cfa2f6b750}\
\GLOBAL??\Volume{d9b257fc-684e-4dcb-ab79-03cfa2f6b750}
Extent: disk=-1 start=0 len=3161088
Mounts:
- X:\
n=2 d=PhysicalDrive-1 f=NTFS p=X:\
* \\?\Volume{4405fc50-9dd2-11ee-a527-806e6f6e6963}\
\GLOBAL??\Volume{4405fc50-9dd2-11ee-a527-806e6f6e6963}
Error: Unable to get volume extents, NTSTATUS=0xC0000010
[0x00000015] The device is not ready.
Mounts:
0: disk=PhysicalDrive0 start=1048576 len=524288000 fs=FAT32 paths=
1: disk=PhysicalDrive-1 start=0 len=3161088 fs=NTFS paths=X:\
lsblk for Windows v1.2, Copyright (c) 2021 Google LLC
NAME HCTL SIZE ST TR RM RO TYPE DESCRIPTION
Disks:
\\.\PhysicalDrive0
PhysicalDrive0 0:0:0:0 56G 1 1 0 0 SATA OCZ-AGILITY3
L Partition 1 500M GPT [System] {C12A7328-F81F-11D2-BA4B-00A0C93EC93B} FAT32
L Partition 2 55G GPT {0FC63DAF-8483-4772-8E79-3D69D8477DE4} FAT32
Partition 2 is "Linux filesystem" (type 0fc63daf-8483-4772-8e79-3d69d8477de4
) with a Btrfs filesystem.
MBR partition type 0x07
nowadays is used for NTFS and exFAT. IFS is an interface OS/2 used to expose to filesystem drivers I think. Linux's libblkid libfdisk is a good source for this kind of stuff:
https://github.com/util-linux/util-linux/blob/v2.39.3/include/pt-mbr-partnames.h#L12
By the way, here is the GPT partition list:
https://github.com/util-linux/util-linux/blob/v2.39.3/include/pt-gpt-partnames.h
It failed in shell output such:
lsblk for Windows v1.2, Copyright (c) 2021 Google LLC
NAME HCTL SIZE ST TR RM RO TYPE DESCRIPTION
PhysicalDrive0 Error: Unable to open \??\PhysicalDrive0, NTSTATUS=0xC0000022
Help clarify the effort to solve
using it in Windows 11,it reports that
it seems that the winapi used in lsblk.c is out of date, cannot been compiled successfully by the latest winlibs-gcc(this one)
reports:
PS D:\workspace\projects\lsblk> gcc lsblk.c -o lsblk -lntdll -lshlwapi
lsblk.c: In function 'ListDisks':
lsblk.c:95:18: warning: implicit declaration of function 'NtOpenDirectoryObject' [-Wimplicit-function-declaration]
95 | status = NtOpenDirectoryObject(&hDir, DIRECTORY_QUERY | DIRECTORY_TRAVERSE, &attr);
| ^~~~~~~~~~~~~~~~~~~~~
lsblk.c:107:26: warning: implicit declaration of function 'NtQueryDirectoryObject' [-Wimplicit-function-declaration]
107 | status = NtQueryDirectoryObject(hDir, DirInfo, sizeof(OBJECT_DIRECTORY_INFORMATION) * nDirInfo, FALSE, first, &index, &bytes);
| ^~~~~~~~~~~~~~~~~~~~~~
lsblk.c: In function 'QueryDisk':
lsblk.c:137:9: error: unknown type name 'GET_DISK_ATTRIBUTES'; did you mean 'SECURITY_ATTRIBUTES'?
137 | GET_DISK_ATTRIBUTES DiskAttributes;
| ^~~~~~~~~~~~~~~~~~~
| SECURITY_ATTRIBUTES
lsblk.c:183:72: error: 'IOCTL_DISK_GET_DISK_ATTRIBUTES' undeclared (first use in this function); did you mean 'IOCTL_VOLUME_GET_GPT_ATTRIBUTES'?
183 | status = NtDeviceIoControlFile(hDisk, NULL, NULL, NULL, &iosb, IOCTL_DISK_GET_DISK_ATTRIBUTES, NULL, 0, &DiskAttributes, sizeof(DiskAttributes));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| IOCTL_VOLUME_GET_GPT_ATTRIBUTES
lsblk.c:183:72: note: each undeclared identifier is reported only once for each function it appears in
lsblk.c:185:49: error: request for member 'Attributes' in something not a structure or union
185 | wprintf(L" %d ", (DiskAttributes.Attributes) ? 0 : 1);
| ^
lsblk.c:223:9: warning: implicit declaration of function 'StrTrimW' [-Wimplicit-function-declaration]
223 | StrTrimW(buff, L" ");
| ^~~~~~~~
lsblk.c:296:29: warning: implicit declaration of function 'IsEqualPartitionType' [-Wimplicit-function-declaration]
296 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_BASIC_DATA_GUID)) wprintf(L" [Basic Data]");
| ^~~~~~~~~~~~~~~~~~~~
lsblk.c:297:99: error: 'PARTITION_BSP_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
297 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_BSP_GUID)) wprintf(L" [BSP]");
| ^~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
lsblk.c:298:99: error: 'PARTITION_CLUSTER_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
298 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_CLUSTER_GUID)) wprintf(L" [Cluster]");
| ^~~~~~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
lsblk.c:299:99: error: 'PARTITION_DPP_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
299 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_DPP_GUID)) wprintf(L" [DPP]");
| ^~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
lsblk.c:302:99: error: 'PARTITION_LEGACY_BL_GUID' undeclared (first use in this function); did you mean 'PARTITION_LDM_DATA_GUID'?
302 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_LEGACY_BL_GUID)) wprintf(L" [Legacy Boot]");
| ^~~~~~~~~~~~~~~~~~~~~~~~
| PARTITION_LDM_DATA_GUID
lsblk.c:303:99: error: 'PARTITION_LEGACY_BL_GUID_BACKUP' undeclared (first use in this function)
303 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_LEGACY_BL_GUID_BACKUP)) wprintf(L" [Legacy Boot Backup]");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lsblk.c:304:99: error: 'PARTITION_MAIN_OS_GUID' undeclared (first use in this function); did you mean 'PARTITION_BASIC_DATA_GUID'?
304 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_MAIN_OS_GUID)) wprintf(L" [OS Main]");
| ^~~~~~~~~~~~~~~~~~~~~~
| PARTITION_BASIC_DATA_GUID
lsblk.c:307:99: error: 'PARTITION_MSFT_SNAPSHOT_GUID' undeclared (first use in this function); did you mean 'PARTITION_MSFT_RECOVERY_GUID'?
307 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_MSFT_SNAPSHOT_GUID)) wprintf(L" [Snapshot]");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| PARTITION_MSFT_RECOVERY_GUID
lsblk.c:308:99: error: 'PARTITION_OS_DATA_GUID' undeclared (first use in this function); did you mean 'PARTITION_LDM_DATA_GUID'?
308 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_OS_DATA_GUID)) wprintf(L" [OS Data]");
| ^~~~~~~~~~~~~~~~~~~~~~
| PARTITION_LDM_DATA_GUID
lsblk.c:309:99: error: 'PARTITION_PATCH_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
309 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_PATCH_GUID)) wprintf(L" [Patch]");
| ^~~~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
lsblk.c:310:99: error: 'PARTITION_PRE_INSTALLED_GUID' undeclared (first use in this function); did you mean 'PARTITION_LDM_DATA_GUID'?
310 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_PRE_INSTALLED_GUID)) wprintf(L" [Preinstall]");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| PARTITION_LDM_DATA_GUID
lsblk.c:311:99: error: 'PARTITION_SPACES_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
311 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_SPACES_GUID)) wprintf(L" [Spaces]");
| ^~~~~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
lsblk.c:312:99: error: 'PARTITION_SPACES_DATA_GUID' undeclared (first use in this function); did you mean 'PARTITION_BASIC_DATA_GUID'?
312 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_SPACES_DATA_GUID)) wprintf(L" [Spaces Data]");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| PARTITION_BASIC_DATA_GUID
lsblk.c:314:99: error: 'PARTITION_WINDOWS_SYSTEM_GUID' undeclared (first use in this function); did you mean 'PARTITION_SYSTEM_GUID'?
314 | if (IsEqualPartitionType(DiskLayout->PartitionEntry[n].Gpt.PartitionType, PARTITION_WINDOWS_SYSTEM_GUID)) wprintf(L" [Windows System]");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| PARTITION_SYSTEM_GUID
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.