Re: [PATCH] mount: Automagically detect and loop-mount regular files.

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

 



On Sat, Jan 09, 2010 at 01:05:04AM +0100, Guillem Jover wrote:
> Hi!
> 
> On Fri, 2010-01-08 at 16:40:51 -0500, Adam Jackson wrote:
> > Signed-off-by: Adam Jackson <ajax@xxxxxxxxxx>
> > ---
> >  mount/mount.c |    6 ++++++
> >  1 files changed, 6 insertions(+), 0 deletions(-)
> > 
> > diff --git a/mount/mount.c b/mount/mount.c
> > index 0cef101..054ea9a 100644
> > --- a/mount/mount.c
> > +++ b/mount/mount.c
> > @@ -1075,6 +1075,12 @@ loop_check(const char **spec, const char **type, int *flags,
> >    *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption);
> >    *loopfile = *spec;
> >  
> > +  if (!*loop) {
> > +    struct stat st_buf;
> > +    stat(*spec, &st_buf);
> > +    *loop = S_ISREG(st_buf.st_mode);
> 
> Shouldn't you check if stat was successful before using st_buf?

Yes. The other problem is that you don't want to use this feature for
pseudo or net filesystems. For example

    # touch /none
    # mount none /proc -t proc

The "none" should be never interpreted as a regular file. So the code
has to be:

    if ((*loop && (*type == NULL || !is_pseudo_fs(*type) || 
                   strcmp(*type, "cifs"))) {
        ....
    }

or so... You don't have to send a new patch. I'll fix it.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux