[PATCH] Add -t noproc,tmpfs options to mount/umount

Bernhard Fischer rep.dot.nop at gmail.com
Wed Apr 4 12:44:04 PDT 2007


On Wed, Apr 04, 2007 at 07:47:49PM +0100, Roy Marples wrote:
>On Wed, 04 Apr 2007 19:56:40 +0200
>Natanael Copa <natanael.copa at gmail.com> wrote:
>> > +static int match_fstype (struct mntent *mt, const char *fstype)
>> > +{
>> > +       bool no = false;
>> > +       char *fst, *p, *token;
>> > +       int retval = 0;
>> > +
>> > +       if (!mt || ! fstype)
>> > +               return -1;
>> > +
>> > +       fst = p = xstrdup (fstype);
>> > +       if (strlen (p) > 2 && p[0] == 'n' && p[1] == 'o') {
>> > +               no = true;
>> > +               p += 2;
>> > +       }
>> 
>> Shouldn't the test for 'no...' be done on the token inside the look
>> below? mount -t nonfs,noshm,ext3,no...
>
>Not really. GNU mount allows nonofs,noshm, whereas BSD mount only
>accepts nonfs,shm. I prefer the BSD approach because you can then
>have a fs name starting with "no" like so
>
>mount -at ,noddy
>
>Also, commenting on my own code
>strlen (p) > 2 && p[0] == 'n' && p[1] == 'o'
>could also be written as
>strncmp (p, "no", 2)
>which may be more readable.

a) put common funcs into libbb/*.c, see loop.c as an example.
b) both strncmp as well as strlen are most likely much bloatier than
needed. Let me point to current trunk's coreutils/dd.c and there the
block below "what == OP_conv". An alternative to strstr is of course
memchr(,,64) or the like.

Care to send an updated patch?
cheers,
>
>> 
>> > +
>> > +       while ((token = strsep (&p, ","))) {
>> > +               if (strcmp (token, mt->mnt_type) == 0) {
>> > +                       if (! no)
>> > +                               retval = 0;
>> > +                       break;
>> > +               }
>> > +       }
>> 
>> Will this really work? seems like only time the func returns anything
>> else but 0 is when either mt or fstype is NULL.
>
>Yes, it works.
>Basically we tokenize the fstype list by ,
>If a token matches the fstype then
>   If list prefixed with no, return -1 otherwise 0.
>If no match found return -1.
>
>
>I also for forgot to mention that the patch also matches the sw option
>to denote swap as well as swap.
>
>Thanks
>
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>


More information about the busybox mailing list