Prevent resizing read-only mounted file systems
Needs RevisionPublic

Authored by shubham on May 17 2019, 7:30 PM.

Diff Detail

Repository
R16 KPMCore
Branch
fs
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11904
Build 11922: arc lint + arc unit
shubham requested review of this revision.May 17 2019, 7:30 PM
shubham created this revision.
stikonas requested changes to this revision.May 17 2019, 7:31 PM
stikonas added inline comments.
src/fs/btrfs.cpp
183

This code should go to filesystem.cpp, it's not btrfs specific.

This revision now requires changes to proceed.May 17 2019, 7:31 PM

Also in general, I think we should create a bool variable where we store data, so that we only run this

src/fs/btrfs.cpp
171–173

I think the issue is that there might some other mount point that is read only even though this mountPoint is RW

shubham updated this revision to Diff 58223.May 17 2019, 7:58 PM

Shift common code to filesystem class

shubham marked 2 inline comments as done.May 17 2019, 7:59 PM

@stikonas Ping?

Sorry, didn't merge it yet... I'll try to test it this weekend and then merge.

stikonas requested changes to this revision.Jan 20 2020, 12:25 AM
stikonas added inline comments.
src/fs/filesystem.cpp
564

I think the code does not yet do the correct thing. In this part of code you scan all volumes on the system.

If there is any volume which is mounted read-only, then this isReadOnly function will return true for all filesystems, so you won't be able to resize any file system.

What we wnat to look over is mount points for given volume, not all mount points on the system.

This revision now requires changes to proceed.Jan 20 2020, 12:25 AM

Sorry for typos, What I meant was:

What we want to loop over is mount points for given volume, not all mount points on the system.

@stikonas I am a bit confused, can you please help a bit?

@stikonas I am a bit confused, can you please help a bit?

Let's say I have the following devices

/dev/sda1 and /dev/sda2.

Let's assume I mount /dev/sda1 to /mnt as read only.

Then let's say /dev/sda2 is the partition I want to resize. Your code will not let me resize /dev/sda2 even though it has no read only mounts.
This happens just because /dev/sda1 was mounted read only as it will be listed in QStorageInfo::mountedVolumes even though /dev/sda1
has nothing to do with /dev/sda2.

What we want to prevent, is if /dev/sda1 is mounted as read-only to /mnt1 (there might or might not be more read-write mounts /mnt2, /mnt3...). We want to disable resizing in this case.

anthonyfieroni added inline comments.
src/fs/btrfs.cpp
171

Pass mountPoint as function parameter but rename it to isWritable

src/fs/filesystem.cpp
558

Make the function with one parameter, found it in mount volumes then return volume.isValid() && volume.isReady() && !volume.isReadOnly()