Skip to content

Commit

Permalink
specify disk path (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ive committed Jan 27, 2024
1 parent 8c43e09 commit 8641d85
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
7 changes: 5 additions & 2 deletions libnw/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,17 @@ PrintDiskInfo(BOOL cdrom, PNODE node, CDI_SMART* smart)
{
PHY_DRIVE_INFO* PhyDriveList = NULL;
DWORD PhyDriveCount = 0, i = 0;
CHAR DiskPath[64];
PhyDriveCount = GetDriveInfoList(cdrom, &PhyDriveList);
if (PhyDriveCount == 0)
goto out;
for (i = 0; i < PhyDriveCount; i++)
{
snprintf(DiskPath, sizeof(DiskPath), cdrom ? "\\\\.\\CdRom%u" : "\\\\.\\PhysicalDrive%u", i);
if (NWLC->DiskPath && _stricmp(NWLC->DiskPath, DiskPath) != 0)
continue;
PNODE nd = NWL_NodeAppendNew(node, "Disk", NFLG_TABLE_ROW);
NWL_NodeAttrSetf(nd, "Path", 0,
cdrom ? "\\\\.\\CdRom%u" : "\\\\.\\PhysicalDrive%u", i);
NWL_NodeAttrSet(nd, "Path",DiskPath, 0);
if (PhyDriveList[i].HwID)
{
WCHAR* hwName = NULL;
Expand Down
1 change: 1 addition & 0 deletions libnw/libnw.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ VOID NW_Init(PNWLIB_CONTEXT pContext)
NWLC->NwFile = stdout;
NWLC->AcpiTable = 0;
NWLC->SmbiosType = 127;
NWLC->DiskPath = NULL;
NWL_NtGetVersion(&NWLC->NwOsInfo);
GetNativeSystemInfo(&NWLC->NwSi);
NWLC->NwRoot = NWL_NodeAlloc("NWinfo", 0);
Expand Down
1 change: 1 addition & 0 deletions libnw/libnw.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef struct _NWLIB_CONTEXT
BOOL SkipVirtualNet;
UINT8 SmbiosType;
LPCSTR PciClass;
LPCSTR DiskPath;
BOOL DisableSmart;

VOID (*SpdProgress) (LPCSTR lpszText);
Expand Down
4 changes: 2 additions & 2 deletions libnw/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#define NWINFO_MAJOR_VERSION 0
#define NWINFO_MINOR_VERSION 9
#define NWINFO_MICRO_VERSION 4
#define NWINFO_BUILD_VERSION 1
#define NWINFO_MICRO_VERSION 5
#define NWINFO_BUILD_VERSION 0

#define NWINFO_VERSION NWINFO_MAJOR_VERSION,NWINFO_MINOR_VERSION,NWINFO_MICRO_VERSION,NWINFO_BUILD_VERSION
#define NWINFO_VERSION_STR QUOTE(NWINFO_MAJOR_VERSION.NWINFO_MINOR_VERSION.NWINFO_MICRO_VERSION.NWINFO_BUILD_VERSION)
Expand Down
33 changes: 24 additions & 9 deletions nwinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,34 @@ static void nwinfo_help(void)
NWINFO_COPYRIGHT "\n"
"Usage: nwinfo OPTIONS\n"
"OPTIONS:\n"
" --format=XXX Specify output format. [YAML|JSON|LUA]\n"
" --format=FMT Specify output format.\n"
" FMT can be 'YAML' (default), 'JSON' and 'LUA'.\n"
" --output=FILE Write to FILE instead of printing to screen.\n"
" --cp=XXXX Set the code page of output text. [ANSI|UTF8]\n"
" --cp=CODEPAGE Set the code page of output text.\n"
" CODEPAGE can be 'ANSI' and 'UTF8'.\n"
" --human Display numbers in human readable format.\n"
" --debug Print debug info to stdout.\n"
" --hide-sensitive Hide sensitive data (MAC & S/N).\n"
" --sys Print system info.\n"
" --cpu Print CPUID info.\n"
" --net[=active] Print [active] network info\n"
" --acpi[=XXXX] Print ACPI [table=XXXX] info.\n"
" --smbios[=XX] Print SMBIOS [type=XX] info.\n"
" --disk Print disk info.\n"
" --net[=FLAG] Print network info\n"
" FLAG can be 'ACTIVE' (print only the active network).\n"
" --acpi[=SGN] Print ACPI info.\n"
" SGN specifies the signature of the ACPI table,\n"
" e.g. 'FACP' (Fixed ACPI Description Table).\n"
" --smbios[=TYPE] Print SMBIOS info.\n"
" TYPE specifies the type of the SMBIOS table,\n"
" e.g. '2' (Base Board Information).\n"
" --disk[=PATH] Print disk info.\n"
" PATH specifies the path of the disk,\n"
" e.g. '\\\\.\\PhysicalDrive0', '\\\\.\\CdRom0'.\n"
" --no-smart Don't print disk S.M.A.R.T. info.\n"
" --display Print EDID info.\n"
" --pci[=XX] Print PCI [class=XX] info.\n"
" --pci[=CLASS] Print PCI info.\n"
" CLASS specifies the class code of pci devices,\n"
" e.g. '0C05' (SMBus).\n"
" --usb Print USB info.\n"
" --spd Print SPD info\n"
" --spd Print SPD info.\n"
" --battery Print battery info.\n"
" --uefi Print UEFI info.\n"
" --shares Print network mapped drives.\n"
Expand Down Expand Up @@ -100,8 +111,12 @@ int main(int argc, char* argv[])
nwContext.SmbiosType = (UINT8)strtoul(&argv[i][9], NULL, 0);
nwContext.DmiInfo = TRUE;
}
else if (_stricmp(argv[i], "--disk") == 0)
else if (_strnicmp(argv[i], "--disk", 6) == 0)
{
if (argv[i][6] == '=' && argv[i][7])
nwContext.DiskPath = &argv[i][7];
nwContext.DiskInfo = TRUE;
}
else if (_stricmp(argv[i], "--no-smart") == 0)
nwContext.DisableSmart = TRUE;
else if (_stricmp(argv[i], "--display") == 0)
Expand Down

0 comments on commit 8641d85

Please sign in to comment.