Skip to content

uucore::fsext: Fix mountinfo parsing w/ multiple optional fields#2778

Merged
sylvestre merged 1 commit into
uutils:masterfrom
refi64:mountinfo-optional
Dec 22, 2021
Merged

uucore::fsext: Fix mountinfo parsing w/ multiple optional fields#2778
sylvestre merged 1 commit into
uutils:masterfrom
refi64:mountinfo-optional

Conversation

@refi64

@refi64 refi64 commented Dec 17, 2021

Copy link
Copy Markdown
Contributor

proc(5) mentions the following for the fields section and hyphen:

(7) optional fields: zero or more fields of the form "tag[:value]";
see below.
(8) separator: the end of the optional fields is marked by a single
hyphen.

IOW, there may actually be multiple optional fields, not just one, in
which case the previously hardcoded indexes for the filesystem type and
device name are now incorrect. Now, the filesystem type and device name
are parsed relative to the hypen's location, ensuring that they will be
correct regardless of the number of optional fields.

Signed-off-by: Ryan Gonzalez ryan.gonzalez@collabora.com

@sylvestre

Copy link
Copy Markdown
Contributor

Would it be possible to add a test for this? thanks

@refi64 refi64 force-pushed the mountinfo-optional branch 2 times, most recently from 2420330 to bc7e4fc Compare December 17, 2021 22:56
@refi64

refi64 commented Dec 17, 2021

Copy link
Copy Markdown
Contributor Author

@sylvestre done!

Comment thread src/uucore/src/lib/features/fsext.rs Outdated
proc(5) mentions the following for the fields section and hyphen:

> (7)  optional fields: zero or more fields of the form "tag[:value]";
> see below.
> (8)  separator: the end of the optional fields is marked by a single
> hyphen.

IOW, there may actually be multiple optional fields, not just one, in
which case the previously hardcoded indexes for the filesystem type and
device name are now incorrect. Now, the filesystem type and device name
are parsed relative to the hypen's location, ensuring that they will be
correct regardless of the number of optional fields.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
@refi64 refi64 force-pushed the mountinfo-optional branch from bc7e4fc to 23c0734 Compare December 20, 2021 14:46
@sylvestre sylvestre merged commit 5c0adb2 into uutils:master Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants