NetBSD Problem Report #15262

Received: (qmail 22834 invoked from network); 16 Jan 2002 13:49:39 -0000
Message-Id: <200201161343.g0GDhkE00643@quiteria>
Date: Wed, 16 Jan 2002 08:43:46 -0500 (EST)
From: dbj@netbsd.org
Reply-To: dbj@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Cc: dbj@netbsd.org
Subject: mount -u and mount -o update take different actions
X-Send-Pr-Version: 3.95

>Number:         15262
>Category:       bin
>Synopsis:       mount -u and mount -o update take different actions
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 16 13:50:01 +0000 2002
>Closed-Date:    
>Last-Modified:  Wed Mar 04 22:45:00 +0000 2026
>Originator:     Darrin B. Jewell
>Release:        NetBSD 1.5ZA 20020105T2358Z
>Organization:
>Environment:
System: NetBSD quiteria 1.5ZA NetBSD 1.5ZA (QUITERIA) #510: Tue Jan 8 05:45:04 EST 2002 dbj@quiteria:/usr/src/sys/arch/macppc/compile/QUITERIA macppc
Architecture: powerpc
Machine: macppc
>Description:
        According to the mount man page, the `-u' mount option
is the same the as using `-o update'.  However, I notice a
difference.

>How-To-Repeat:
# mount
/dev/wd0a on / type ffs (local, noatime, nodevmtime)
# cat /etc/fstab
#       $NetBSD: fstab.wd,v 1.1 2000/06/12 23:06:59 matt Exp $
#
/dev/wd0a       /       ffs     rw,noatime,nodevmtime 1 1
# mount /
# mount
/dev/wd0a on / type ffs (local, noatime, nodevmtime)
# mount -u /
# mount
/dev/wd0a on / type ffs (local)
# mount -o update /
# mount
/dev/wd0a on / type ffs (local, noatime, nodevmtime)
# mount -u /
# mount
/dev/wd0a on / type ffs (local)
# mount -o update /
# mount
/dev/wd0a on / type ffs (local, noatime, nodevmtime)

>Fix:

>Release-Note:
>Audit-Trail:
From: Jacob Pipkin <jacob.pipkin@icloud.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/15262
Date: Mon, 2 Mar 2026 17:18:56 -0600

 This should just be a matter of skipping the FLG_UPDATE code path with
 -u and just setting the "update" option directly. Here are my test
 results:
 --
 # grep noatime /etc/fstab
 NAME=70c33570-9733-3a44-b5b8-7351a1b600f0               /       ffs
 rw,noatime               1 1
 # mount | grep ' / '
 /dev/dk1 on / type ffs (local)
 # ./mount -u /
 # mount | grep ' / '
 /dev/dk1 on / type ffs (noatime, local)
 # ./mount -o update /
 # mount | grep ' / '
 /dev/dk1 on / type ffs (noatime, local)
 --

 Shiny. Here's the patch:

 Index: mount.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/mount/mount.c,v
 retrieving revision 1.108
 diff -u -r1.108 mount.c
 --- mount.c 1 Jul 2025 17:55:05 -0000   1.108
 +++ mount.c 2 Mar 2026 23:00:01 -0000
 @@ -150,7 +150,7 @@
             vfstype = optarg;
             break;
         case 'u':
 -           init_flags |= FLG_UPDATE;
 +           catopt(&options, "update");
             break;
         case 'v':
             verbose++;
 @@ -229,60 +229,35 @@
          */
         canonical_path = realpath(*argv, canonical_path_buf);

 -       if (init_flags & FLG_UPDATE) {
 -           /*
 -            * Try looking up the canonical path first,
 -            * then try exactly what the user entered.
 -            */
 -           if ((canonical_path == NULL ||
 -               (mntbuf = getmntpt(canonical_path)) == NULL) &&
 -               (mntbuf = getmntpt(*argv)) == NULL) {
 -out:
 -               errx(EXIT_FAILURE,
 -                   "Unknown special file or file system `%s'",
 -                   *argv);
 -           }
 -           mntfromname = mntbuf->f_mntfromname;
 -           if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
 -               if (strcmp(fs->fs_spec, "from_mount") != 0)
 -                   mntfromname = fs->fs_spec;
 -               /* ignore the fstab file options.  */
 -               fs->fs_mntops = NULL;
 -           }
 -           mntonname  = mntbuf->f_mntonname;
 -           fstypename = mntbuf->f_fstypename;
 -           mountopts  = NULL;
 -       } else {
 -           /*
 -            * Try looking up the canonical path first,
 -            * then try exactly what the user entered.
 -            */
 -           if (canonical_path == NULL ||
 -               ((fs = getfsfile(canonical_path)) == NULL &&
 -                (fs = getfsspec(canonical_path)) == NULL))
 -           {
 -               if ((fs = getfsfile(*argv)) == NULL &&
 -                   (fs = getfsspec(*argv)) == NULL) {
 -                   goto out;
 -               }
 +       /*
 +        * Try looking up the canonical path first,
 +        * then try exactly what the user entered.
 +        */
 +       if (canonical_path == NULL ||
 +           ((fs = getfsfile(canonical_path)) == NULL &&
 +            (fs = getfsspec(canonical_path)) == NULL))
 +       {
 +           if ((fs = getfsfile(*argv)) == NULL &&
 +               (fs = getfsspec(*argv)) == NULL) {
 +               goto out;
             }
 -           if (BADTYPE(fs->fs_type))
 -               errx(EXIT_FAILURE,
 -                   "Unknown file system type for `%s'",
 -                   *argv);
 -           if (strcmp(fs->fs_spec, "from_mount") == 0) {
 -               if ((canonical_path == NULL ||
 -                   (mntbuf = getmntpt(canonical_path))
 -                    == NULL) &&
 -                   (mntbuf = getmntpt(*argv)) == NULL)
 -                   goto out;
 -               mntfromname = mntbuf->f_mntfromname;
 -           } else
 -               mntfromname = fs->fs_spec;
 -           mntonname   = fs->fs_file;
 -           fstypename  = fs->fs_vfstype;
 -           mountopts   = fs->fs_mntops;
         }
 +       if (BADTYPE(fs->fs_type))
 +           errx(EXIT_FAILURE,
 +               "Unknown file system type for `%s'",
 +               *argv);
 +       if (strcmp(fs->fs_spec, "from_mount") == 0) {
 +           if ((canonical_path == NULL ||
 +               (mntbuf = getmntpt(canonical_path))
 +                == NULL) &&
 +               (mntbuf = getmntpt(*argv)) == NULL)
 +               goto out;
 +           mntfromname = mntbuf->f_mntfromname;
 +       } else
 +           mntfromname = fs->fs_spec;
 +       mntonname   = fs->fs_file;
 +       fstypename  = fs->fs_vfstype;
 +       mountopts   = fs->fs_mntops;
         mntfromname = getfsspecname(buf, sizeof(buf), mntfromname);
         if (mntfromname == NULL)
             err(EXIT_FAILURE, "%s", buf);

From: "Darrin B. Jewell" <dbj@mit.edu>
To: "Jacob Pipkin via gnats" <gnats-admin@NetBSD.org>
Cc: netbsd-bugs@netbsd.org, dbj@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: bin/15262
Date: Wed, 04 Mar 2026 13:38:39 -0800

 It has been a long time since I've been familiar with this code path
 so don't block this on me.  Thanks for taking look at it.

 Darrin

 "Jacob Pipkin via gnats" <gnats-admin@NetBSD.org> writes:

 > The following reply was made to PR bin/15262; it has been noted by GNATS.
 >
 > From: Jacob Pipkin <jacob.pipkin@icloud.com>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: bin/15262
 > Date: Mon, 2 Mar 2026 17:18:56 -0600
 >
 >  This should just be a matter of skipping the FLG_UPDATE code path with
 >  -u and just setting the "update" option directly. Here are my test
 >  results:
 >  --
 >  # grep noatime /etc/fstab
 >  NAME=70c33570-9733-3a44-b5b8-7351a1b600f0               /       ffs
 >  rw,noatime               1 1
 >  # mount | grep ' / '
 >  /dev/dk1 on / type ffs (local)
 >  # ./mount -u /
 >  # mount | grep ' / '
 >  /dev/dk1 on / type ffs (noatime, local)
 >  # ./mount -o update /
 >  # mount | grep ' / '
 >  /dev/dk1 on / type ffs (noatime, local)
 >  --
 >  
 >  Shiny. Here's the patch:
 >  
 >  Index: mount.c
 >  ===================================================================
 >  RCS file: /cvsroot/src/sbin/mount/mount.c,v
 >  retrieving revision 1.108
 >  diff -u -r1.108 mount.c
 >  --- mount.c 1 Jul 2025 17:55:05 -0000   1.108
 >  +++ mount.c 2 Mar 2026 23:00:01 -0000
 >  @@ -150,7 +150,7 @@
 >              vfstype = optarg;
 >              break;
 >          case 'u':
 >  -           init_flags |= FLG_UPDATE;
 >  +           catopt(&options, "update");
 >              break;
 >          case 'v':
 >              verbose++;
 >  @@ -229,60 +229,35 @@
 >           */
 >          canonical_path = realpath(*argv, canonical_path_buf);
 >   
 >  -       if (init_flags & FLG_UPDATE) {
 >  -           /*
 >  -            * Try looking up the canonical path first,
 >  -            * then try exactly what the user entered.
 >  -            */
 >  -           if ((canonical_path == NULL ||
 >  -               (mntbuf = getmntpt(canonical_path)) == NULL) &&
 >  -               (mntbuf = getmntpt(*argv)) == NULL) {
 >  -out:
 >  -               errx(EXIT_FAILURE,
 >  -                   "Unknown special file or file system `%s'",
 >  -                   *argv);
 >  -           }
 >  -           mntfromname = mntbuf->f_mntfromname;
 >  -           if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
 >  -               if (strcmp(fs->fs_spec, "from_mount") != 0)
 >  -                   mntfromname = fs->fs_spec;
 >  -               /* ignore the fstab file options.  */
 >  -               fs->fs_mntops = NULL;
 >  -           }
 >  -           mntonname  = mntbuf->f_mntonname;
 >  -           fstypename = mntbuf->f_fstypename;
 >  -           mountopts  = NULL;
 >  -       } else {
 >  -           /*
 >  -            * Try looking up the canonical path first,
 >  -            * then try exactly what the user entered.
 >  -            */
 >  -           if (canonical_path == NULL ||
 >  -               ((fs = getfsfile(canonical_path)) == NULL &&
 >  -                (fs = getfsspec(canonical_path)) == NULL))
 >  -           {
 >  -               if ((fs = getfsfile(*argv)) == NULL &&
 >  -                   (fs = getfsspec(*argv)) == NULL) {
 >  -                   goto out;
 >  -               }
 >  +       /*
 >  +        * Try looking up the canonical path first,
 >  +        * then try exactly what the user entered.
 >  +        */
 >  +       if (canonical_path == NULL ||
 >  +           ((fs = getfsfile(canonical_path)) == NULL &&
 >  +            (fs = getfsspec(canonical_path)) == NULL))
 >  +       {
 >  +           if ((fs = getfsfile(*argv)) == NULL &&
 >  +               (fs = getfsspec(*argv)) == NULL) {
 >  +               goto out;
 >              }
 >  -           if (BADTYPE(fs->fs_type))
 >  -               errx(EXIT_FAILURE,
 >  -                   "Unknown file system type for `%s'",
 >  -                   *argv);
 >  -           if (strcmp(fs->fs_spec, "from_mount") == 0) {
 >  -               if ((canonical_path == NULL ||
 >  -                   (mntbuf = getmntpt(canonical_path))
 >  -                    == NULL) &&
 >  -                   (mntbuf = getmntpt(*argv)) == NULL)
 >  -                   goto out;
 >  -               mntfromname = mntbuf->f_mntfromname;
 >  -           } else
 >  -               mntfromname = fs->fs_spec;
 >  -           mntonname   = fs->fs_file;
 >  -           fstypename  = fs->fs_vfstype;
 >  -           mountopts   = fs->fs_mntops;
 >          }
 >  +       if (BADTYPE(fs->fs_type))
 >  +           errx(EXIT_FAILURE,
 >  +               "Unknown file system type for `%s'",
 >  +               *argv);
 >  +       if (strcmp(fs->fs_spec, "from_mount") == 0) {
 >  +           if ((canonical_path == NULL ||
 >  +               (mntbuf = getmntpt(canonical_path))
 >  +                == NULL) &&
 >  +               (mntbuf = getmntpt(*argv)) == NULL)
 >  +               goto out;
 >  +           mntfromname = mntbuf->f_mntfromname;
 >  +       } else
 >  +           mntfromname = fs->fs_spec;
 >  +       mntonname   = fs->fs_file;
 >  +       fstypename  = fs->fs_vfstype;
 >  +       mountopts   = fs->fs_mntops;
 >          mntfromname = getfsspecname(buf, sizeof(buf), mntfromname);
 >          if (mntfromname == NULL)
 >              err(EXIT_FAILURE, "%s", buf);
 >  

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.