General TC > Programming & Scripting - Unofficial

Tinkering with rebuildfstab

<< < (6/8) > >>

curaga:
Custom mounts: say you have a line mounting /dev/sda1 to /files.

The primary caller of rebuildfstab is udev. The other known callers are at boot time and mnttool, and mnttool does not expect that behavior. So I don't think such a guarantee is needed.

Rich:
Hi curaga

--- Quote from: curaga on March 06, 2023, 01:28:02 PM ---Custom mounts: say you have a line mounting /dev/sda1 to /files. ...
--- End quote ---
Do you mean something like this might already be in  /etc/fstab:

--- Code: ---/dev/sda1       /files          ext4     noauto,users,exec    0 0
--- End code ---
and in this example I should skip adding:

--- Code: ---/dev/sda1       /mnt/sda1       ext4     noauto,users,exec    0 0 # Added by TC
--- End code ---

CNK:
The old (TC13) script checked the "$TMP" list of manually-generated fstab entries for any entry already matching the device that it was about to add. It called grep once per round to do this.

One alternative approach besides the Awk solution in the new script (which I don't understand Awk well enough to touch), would be to use "grep -v" to exclude from the lines fed to the "while read" loop all those matching the first field in existing fstab entries stored in $TMP.

For example if you have "grep $FILTERS -v /proc/partitions | while read -r DEVMAJOR DEVMINOR BLOCKS DEVNAME". Start with FILTERS="-e 'loop[0-9]*$' -e 'ram[0-9]*$' -e '^$' -e ' name$'", then write a loop that adds an "-e" onto $FILTERS for each first field of "$TMP". EDIT: "grep $FILTERS -v /proc/partitions" doesn't work, I haven't got time to figure out exactly how wrong I am here...

I didn't really have time to write this post clearly, sorry if it's just confusing.

CNK:

--- Quote from: CNK on March 06, 2023, 08:55:39 PM ---For example if you have "grep $FILTERS -v /proc/partitions | while read -r DEVMAJOR DEVMINOR BLOCKS DEVNAME". Start with FILTERS="-e 'loop[0-9]*$' -e 'ram[0-9]*$' -e '^$' -e ' name$'", then write a loop that adds an "-e" onto $FILTERS for each first field of "$TMP". EDIT: "grep $FILTERS -v /proc/partitions" doesn't work, I haven't got time to figure out exactly how wrong I am here...

--- End quote ---

Use backslashes (\) to escape the spaces between arguments, instead of double quotes ("), when setting the FILTERS variable and it works.

curaga:
Rich, precisely.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version