Skip to content

Commit a0ad38d

Browse files
committed
Disk: check for mntopt instead of statvfs when detecting read only flags
Ref: #1343
1 parent cc86c2c commit a0ad38d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/detection/disk/disk_linux.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static bool isRemovable(FFDisk* currentDisk)
215215
return ffReadFileData(sysBlockVolume, 1, &removableChar) > 0 && removableChar == '1';
216216
}
217217

218-
static void detectType(const FFlist* disks, FFDisk* currentDisk)
218+
static void detectType(const FFlist* disks, FFDisk* currentDisk, struct mntent* device)
219219
{
220220
if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/boot") || ffStrbufStartsWithS(&currentDisk->mountpoint, "/efi"))
221221
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
@@ -225,6 +225,8 @@ static void detectType(const FFlist* disks, FFDisk* currentDisk)
225225
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
226226
else
227227
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
228+
if (hasmntopt(device, MNTOPT_RO))
229+
currentDisk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
228230
}
229231

230232
#endif
@@ -251,9 +253,6 @@ static void detectStats(FFDisk* disk)
251253
disk->filesTotal = disk->filesUsed = 0;
252254
}
253255

254-
if(fs.f_flag & ST_RDONLY)
255-
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
256-
257256
disk->createTime = 0;
258257
#ifdef FF_HAVE_STATX
259258
struct statx stx;
@@ -298,7 +297,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
298297
detectName(disk); // Also detects external devices
299298

300299
//detect type
301-
detectType(disks, disk);
300+
detectType(disks, disk, device);
302301

303302
//Detects stats
304303
detectStats(disk);

src/detection/disk/disk_sunos.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk)
7272

7373
static void detectType(const FFlist* disks, FFDisk* currentDisk, struct mnttab* device)
7474
{
75-
if(ffStrContains(device->mnt_mntopts, MNTOPT_NOBROWSE))
75+
if(hasmntopt(device, MNTOPT_NOBROWSE))
7676
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
7777
else if(isSubvolume(disks, currentDisk))
7878
currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
7979
else
8080
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
81+
if (hasmntopt(device, MNTOPT_RO))
82+
currentDisk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
8183
}
8284

8385
static void detectStats(FFDisk* disk)
@@ -94,9 +96,6 @@ static void detectStats(FFDisk* disk)
9496
disk->filesTotal = (uint32_t) fs.f_files;
9597
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
9698

97-
if(fs.f_flag & ST_RDONLY)
98-
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
99-
10099
ffStrbufSetS(&disk->name, fs.f_fstr);
101100

102101
disk->createTime = 0;

0 commit comments

Comments
 (0)