Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Fixing swap1_stop



    Date:        Thu, 17 Aug 2017 21:36:18 -0400
    From:        "Ian D. Leroux" <idleroux%fastmail.fm@localhost>
    Message-ID:  <20170817213618.1c7316846f102e054bf8972e%fastmail.fm@localhost>

  | Fair enough, though I don't find inserting '\'' much harder
  | (particularly since there's already a function in our standard library
  | to do it)

Of course, and that function will do it for the $'' case as well...

  | In a sense, the whole discussion is moot.  The implementation of 'mount
  | -p' should just use shquote(3)

Agreed, that is what I did.

  | As and when $' gets implemented in both /bin/sh and shquote(3)

Done.   Not ready to commit yet, both need more testing, ATF tests written,
and man page updates first, but it is all working well enough for the
demonstration below (and the mount changes need even more than that - 
see below.)

  | the output format will
  | be upgraded as you suggest with no changes to the mount source code.

Yes, that worked ... when I first did this I put my shquote(3) changes in
the wrong source tree (you don't want to know ...) so they were omitted
when I first tested the mods below.  It all worked similarly to
as shown below except with only '' quoting being used.   That turns out to
be a bit ugly to look at, as shquote() as it is currently always quotes, even
for trivial strings like /tmp (there's even a comment in the source that
suggests this might be fixed sometime ... that happened)

  | I'm off the net for the weekend, but I'll probably take a crack at this
  | next week.

Before I show what I currently have, let me say that I know the options
are all wrong - it needs to use MNT_OPTS not MNT_FLAGS when extracting the
-o values (and also needs to learn about quotas & the "no" options), but
that's all just a SMOP - I'll fix that later today sometime (this was just
easy to cut/paste from the current prmount() function..,  and it illustrates
better how shquote() is being used - the correct options would not contain
spaces in their names.)   The amount of code in mount for this is quite small
though it will need to grow a bit.

So, on my test system:

netbsd# mount
/dev/xbd0a on / type ffs (local)
tmpfs on /tmp type tmpfs (local)
ptyfs on /dev/pts type ptyfs (hidden, local)
tmpfs on /foo/bar
/foo/baz type tmpfs (local)
tmpfs on /dev ice directory type tmpfs (local)
onyx:/local/netbsd/src on /usr/src type nfs (read-only)
onyx:/local/distfiles on /local/distfiles type nfs (read-only)

netbsd# mount -p mount
mount -t ffs -o 'local,root file system' /dev/xbd0a /
mount -t tmpfs -o local tmpfs /tmp
mount -t ptyfs -o hidden,local ptyfs /dev/pts
mount -t tmpfs -o local tmpfs $'/foo/bar\n/foo/baz'
mount -t tmpfs -o local tmpfs '/dev ice directory'
mount -t nfs -o read-only onyx:/local/netbsd/src /usr/src
mount -t nfs -o read-only onyx:/local/distfiles /local/distfiles

netbsd# mount -t tmpfs -p ''
tmpfs local tmpfs /tmp
tmpfs local tmpfs $'/foo/bar\n/foo/baz'
tmpfs local tmpfs '/dev ice directory'

(with -p '' there are always 4 words on each line, the options will
appear as '' if there are none to print - with -p word the -o opts args
are just omitted in that case.)

netbsd# mount -t tmpfs -p 'FOO' | grep baz
FOO -t tmpfs -o local tmpfs $'/foo/bar\n/foo/baz'

That one was manufactured using ...

netbsd# mkdir -p $'/foo/bar\n/foo/baz'
netbsd# mount -t tmpfs tmpfs  $'/foo/bar\n/foo/baz'

it obviously cannot go in fstab!

And after:

netbsd# mount -t tmpfs -r tmpfs /tmp/unwritable

we get:

netbsd# mount -p '' -t tmpfs
tmpfs local tmpfs /tmp
tmpfs local tmpfs $'/foo/bar\n/foo/baz'
tmpfs local tmpfs '/dev ice directory'
tmpfs read-only,local tmpfs /tmp/unwritable

though I am not sure what a ro tmpfs is useful for (I did this here
just to show the options in this format when there is more than one.)


Does this look like something that you could use (that is, once completed) ?

kre

and just for fun (with -p, -v does nothing):

netbsd# mount -v                                                                /dev/xbd0a on / type ffs (local, root file system, fsid: 0x8e00/0x78b, reads: sync 27136 async 1, writes: sync 122 async 420)
tmpfs on /tmp type tmpfs (local, fsid: 0xab01/0x69ab, reads: sync 0 async 0, writes: sync 0 async 0)
ptyfs on /dev/pts type ptyfs (hidden, local, fsid: 0x7b01/0x6b7b, reads: sync 0 async 0, writes: sync 0 async 0)
tmpfs on /foo/bar
/foo/baz type tmpfs (local, fsid: 0xab02/0x69ab, reads: sync 0 async 0, writes: sync 0 async 0)
tmpfs on /dev ice directory type tmpfs (local, fsid: 0xab03/0x69ab, reads: sync 0 async 0, writes: sync 0 async 0)
onyx:/local/netbsd/src on /usr/src type nfs (read-only, fsid: 0xb03/0x70b, reads: sync 0 async 0, writes: sync 0 async 0)
onyx:/local/distfiles on /local/distfiles type nfs (read-only, fsid: 0xb04/0x70b, reads: sync 0 async 0, writes: sync 0 async 0)
tmpfs on /tmp/unwritable type tmpfs (read-only, local, fsid: 0xab04/0x69ab, reads: sync 0 async 0, writes: sync 0 async 0)




Home | Main Index | Thread Index | Old Index