BUGFIX: fstab comments made invalid format error

This commit is contained in:
yo 2023-11-09 19:16:53 +01:00
parent 7e1c213ff4
commit 69665fdcef

View File

@ -917,7 +917,8 @@ func getFstab(path string) ([]Mount, error) {
scan := bufio.NewScanner(f) scan := bufio.NewScanner(f)
for scan.Scan() { for scan.Scan() {
res := strings.Fields(scan.Text()) res := strings.Fields(scan.Text())
if len(res) != 6 { // iocage create lines like that : "/iocage/releases/13.2-RELEASE/root/bin /iocage/jails/smtp-router-02/root/bin nullfs ro 0 0 # Added by iocage on 2023-10-10 17:20:51"
if (len(res) > 6 && !strings.EqualFold(res[6], "#")) || len(res) < 6 {
return mounts, fmt.Errorf("Incorrect format for fstab line %s", scan.Text()) return mounts, fmt.Errorf("Incorrect format for fstab line %s", scan.Text())
} }
freq, err := strconv.Atoi(res[4]) freq, err := strconv.Atoi(res[4])