Skip to content

Commit

Permalink
quick: Adding anonymous union to begin name change on filesystem stru…
Browse files Browse the repository at this point in the history
…cture

Adding an anonymous union to begin the namechange for an old variable to make the name more clear. Using "hasActiveFileSystem" to be more helpful in noting that it is something that is currently mounted.
This is far from perfect, but will cover most of the file systems out there.

[#10]

Signed-off-by: Tyler Erickson <[email protected]>
  • Loading branch information
vonericsen committed Jun 22, 2022
1 parent 8c0b0ea commit d7fc8ef
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
5 changes: 4 additions & 1 deletion include/common_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,10 @@ extern "C"
unsigned int last_error; // errno in Linux or GetLastError in Windows.
struct {
bool fileSystemInfoValid;//This must be set to true for the other bools to have any meaning. This is here because some OS's may not have support for detecting this information
bool hasFileSystem;//This will only be true for filesystems the current OS can detect. Ex: Windows will only set this for mounted volumes it understands (NTFS, FAT32, etc). Linux may set this for more filesystem types since it can handle more than Windows by default
union {
bool hasFileSystem;//[deprecated], use the hasActiveFileSystem below. This will only be true for filesystems the current OS can detect. Ex: Windows will only set this for mounted volumes it understands (NTFS, FAT32, etc). Linux may set this for more filesystem types since it can handle more than Windows by default
bool hasActiveFileSystem;//This is a bit more clear that the filesystem detected was mounted and is in use within the OS.
};
bool isSystemDisk;//This will be set if the drive has a file system and the OS is running off of it. Ex: Windows' C:\Windows\System32, Linux's / & /boot, etc
}fileSystemInfo;
ptrCsmiDeviceInfo csmiDeviceData;//This is a pointer because it will only be allocated when CSMI is supported. This is also used by Intel RST NVMe passthrough which is basically an extension of CSMI
Expand Down
6 changes: 3 additions & 3 deletions src/cam_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static int set_Device_Partition_Info(tDevice* device)
if (partitionCount > 0)
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
ptrsPartitionInfo parts = C_CAST(ptrsPartitionInfo, calloc(partitionCount, sizeof(spartitionInfo)));
if (parts)
Expand All @@ -155,7 +155,7 @@ static int set_Device_Partition_Info(tDevice* device)
for (; iter < partitionCount; ++iter)
{
//since we found a partition, set the "has file system" bool to true
device->os_info.fileSystemInfo.hasFileSystem = true;
device->os_info.fileSystemInfo.hasActiveFileSystem = true;
#if defined (_DEBUG)
printf("Found mounted file system: %s - %s\n", (parts + iter)->fsName, (parts + iter)->mntPath);
#endif
Expand All @@ -180,7 +180,7 @@ static int set_Device_Partition_Info(tDevice* device)
else
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
}
return ret;
Expand Down
6 changes: 3 additions & 3 deletions src/sg_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ static int set_Device_Partition_Info(tDevice* device)
if (partitionCount > 0)
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
ptrsPartitionInfo parts = C_CAST(ptrsPartitionInfo, calloc(partitionCount, sizeof(spartitionInfo)));
if (parts)
Expand All @@ -963,7 +963,7 @@ static int set_Device_Partition_Info(tDevice* device)
for (; iter < partitionCount; ++iter)
{
//since we found a partition, set the "has file system" bool to true
device->os_info.fileSystemInfo.hasFileSystem = true;
device->os_info.fileSystemInfo.hasActiveFileSystem = true;
#if defined (_DEBUG)
printf("Found mounted file system: %s - %s\n", (parts + iter)->fsName, (parts + iter)->mntPath);
#endif
Expand All @@ -988,7 +988,7 @@ static int set_Device_Partition_Info(tDevice* device)
else
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
}
return ret;
Expand Down
6 changes: 3 additions & 3 deletions src/uscsi_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int set_Device_Partition_Info(tDevice* device)
if (partitionCount > 0)
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
ptrsPartitionInfo parts = C_CAST(ptrsPartitionInfo, calloc(partitionCount, sizeof(spartitionInfo)));
if (parts)
Expand All @@ -144,7 +144,7 @@ static int set_Device_Partition_Info(tDevice* device)
for (; iter < partitionCount; ++iter)
{
//since we found a partition, set the "has file system" bool to true
device->os_info.fileSystemInfo.hasFileSystem = true;
device->os_info.fileSystemInfo.hasActiveFileSystem = true;
#if defined (_DEBUG)
printf("Found mounted file system: %s - %s\n", (parts + iter)->fsName, (parts + iter)->mntPath);
#endif
Expand All @@ -169,7 +169,7 @@ static int set_Device_Partition_Info(tDevice* device)
else
{
device->os_info.fileSystemInfo.fileSystemInfoValid = true;
device->os_info.fileSystemInfo.hasFileSystem = false;
device->os_info.fileSystemInfo.hasActiveFileSystem = false;
device->os_info.fileSystemInfo.isSystemDisk = false;
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/win_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3862,7 +3862,7 @@ static int get_Win_Device(const char *filename, tDevice *device )
{
if (diskExtents->Extents[counter].DiskNumber == device->os_info.os_drive_number)
{
device->os_info.fileSystemInfo.hasFileSystem = true;//We found a filesystem for this drive, so set this to true.
device->os_info.fileSystemInfo.hasActiveFileSystem = true;//We found a filesystem for this drive, so set this to true.

//Set a bit to note that this particular volume (letter) is on this device
device->os_info.volumeBitField |= (UINT32_C(1) << volumeCounter);
Expand Down

0 comments on commit d7fc8ef

Please sign in to comment.