Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw
Signed-off-by: Kairui Song kasong@redhat.com --- mkdumprd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mkdumprd b/mkdumprd index de9ca48..6fc68fe 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,14 +106,14 @@ to_mount() { _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') fi fi + # mount fs target as rw in 2nd kernel + _options=$(echo $_options | sed 's/(^|,)ro($|,)/\1rw\2/g') # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here. - _options=$(echo $_options | sed 's/\bnoauto\b//') - #mount fs target as rw in 2nd kernel - _options=$(echo $_options | sed 's/\bro\b/rw/') + _options=$(echo $_options | sed 's/(^|,)noauto($|,)/\1/g') # drop nofail or nobootwait - _options=$(echo $_options | sed 's/\bnofail\b//') - _options=$(echo $_options | sed 's/\bnobootwait\b//') + _options=$(echo $_options | sed 's/(^|,)nofail($|,)/\1/g') + _options=$(echo $_options | sed 's/(^|,)nobootwait($|,)/\1/g')
_mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name
On 01/28/19 at 01:21pm, Kairui Song wrote:
Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw
Has it cover white space arounded word eg. " ro" " ro "?
Signed-off-by: Kairui Song kasong@redhat.com
mkdumprd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mkdumprd b/mkdumprd index de9ca48..6fc68fe 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,14 +106,14 @@ to_mount() { _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') fi fi
- # mount fs target as rw in 2nd kernel
- _options=$(echo $_options | sed 's/(^|,)ro($|,)/\1rw\2/g') # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here.
- _options=$(echo $_options | sed 's/\bnoauto\b//')
- #mount fs target as rw in 2nd kernel
- _options=$(echo $_options | sed 's/\bro\b/rw/')
- _options=$(echo $_options | sed 's/(^|,)noauto($|,)/\1/g') # drop nofail or nobootwait
- _options=$(echo $_options | sed 's/\bnofail\b//')
- _options=$(echo $_options | sed 's/\bnobootwait\b//')
_options=$(echo $_options | sed 's/(^|,)nofail($|,)/\1/g')
_options=$(echo $_options | sed 's/(^|,)nobootwait($|,)/\1/g')
_mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name
-- 2.20.1
On Mon, Jan 28, 2019 at 1:36 PM Dave Young dyoung@redhat.com wrote:
On 01/28/19 at 01:21pm, Kairui Song wrote:
Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw
Has it cover white space arounded word eg. " ro" " ro "?
Hi Dave, I'm not sure what do you mean about the white space. In mkdumprd, "findmnt -k -f -n -r -o OPTIONS" is used for retrieving the option, so there should not be tailing or leading white space. Even if there is space in options (like pathname) it will truncate it:
eg. if we have: overlay on /mnt/root/upper type overlay (rw,relatime,seclabel,lowerdir=/mnt/root/name with space,upperdir=/mnt/root/upper,workdir=/mnt/root/work)
findmnt will give this output: $ findmnt -k -n -r -f /mnt/root/upper/ -o OPTIONS rw,relatime,seclabel,lowerdir=/mnt/root/name\x20with\x20space,upperdir=/mnt/root/upper,workdir=/mnt/root/work
Also for lines in fstab no space is allowed, need to be truncated to \040 or will get an error like this: /etc/fstab: parse error at line 17 -- ignored
On 01/28/19 at 02:22pm, Kairui Song wrote:
On Mon, Jan 28, 2019 at 1:36 PM Dave Young dyoung@redhat.com wrote:
On 01/28/19 at 01:21pm, Kairui Song wrote:
Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw
Has it cover white space arounded word eg. " ro" " ro "?
Hi Dave, I'm not sure what do you mean about the white space. In mkdumprd, "findmnt -k -f -n -r -o OPTIONS" is used for retrieving the option, so there should not be tailing or leading white space. Even if there is space in options (like pathname) it will truncate it:
eg. if we have: overlay on /mnt/root/upper type overlay (rw,relatime,seclabel,lowerdir=/mnt/root/name with space,upperdir=/mnt/root/upper,workdir=/mnt/root/work)
findmnt will give this output: $ findmnt -k -n -r -f /mnt/root/upper/ -o OPTIONS rw,relatime,seclabel,lowerdir=/mnt/root/name\x20with\x20space,upperdir=/mnt/root/upper,workdir=/mnt/root/work
Also for lines in fstab no space is allowed, need to be truncated to \040 or will get an error like this: /etc/fstab: parse error at line 17 -- ignored
oops, I wrongly consider it as kernel cmdline, please ignore the comment then.
-- Best Regards, Kairui Song
On 01/28/19 at 01:21pm, Kairui Song wrote:
Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw
Signed-off-by: Kairui Song kasong@redhat.com
mkdumprd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mkdumprd b/mkdumprd index de9ca48..6fc68fe 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,14 +106,14 @@ to_mount() { _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') fi fi
- # mount fs target as rw in 2nd kernel
- _options=$(echo $_options | sed 's/(^|,)ro($|,)/\1rw\2/g') # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here.
- _options=$(echo $_options | sed 's/\bnoauto\b//')
- #mount fs target as rw in 2nd kernel
- _options=$(echo $_options | sed 's/\bro\b/rw/')
- _options=$(echo $_options | sed 's/(^|,)noauto($|,)/\1/g') # drop nofail or nobootwait
- _options=$(echo $_options | sed 's/\bnofail\b//')
- _options=$(echo $_options | sed 's/\bnobootwait\b//')
_options=$(echo $_options | sed 's/(^|,)nofail($|,)/\1/g')
_options=$(echo $_options | sed 's/(^|,)nobootwait($|,)/\1/g')
_mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name
-- 2.20.1
Acked-by: Dave Young dyoung@redhat.com
Thanks Dave