delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/05/12/06:54:43

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sat, 12 May 2012 12:53:49 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com, Jeremy Allison <jra AT samba DOT org>
Cc: starlight DOT 2012q2 AT binnacle DOT cx
Subject: Re: CYGWIN inode over Samba share not constructed from IndexNumber
Message-ID: <20120512105349.GM13090@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com, Jeremy Allison <jra AT samba DOT org>, starlight DOT 2012q2 AT binnacle DOT cx
References: <6 DOT 2 DOT 5 DOT 6 DOT 2 DOT 20120511125624 DOT 05cd1ff8 AT binnacle DOT cx> <20120511175843 DOT GL13090 AT calimero DOT vinschen DOT de> <20120511211532 DOT GB2278 AT jeremy-laptop>
MIME-Version: 1.0
In-Reply-To: <20120511211532.GB2278@jeremy-laptop>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Hi Jeremy,

On May 11 14:15, Jeremy Allison wrote:
> On Fri, May 11, 2012 at 07:58:43PM +0200, Corinna Vinschen wrote:
> > On May 11 12:56, starlight DOT 2012q2 AT binnacle DOT cx wrote:
> > > /********************************************************************
> > >  Create a 64 bit FileIndex. If the file is on the same device as
> > >  the root of the share, just return the 64-bit inode. If it isn't,
> > >  mangle as we used to do.
> > > ********************************************************************/
> > > 
> > > uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf)
> > > {
> > >    uint64_t file_index;
> > >    if (conn->base_share_dev == psbuf->st_ex_dev) {
> > >       return (uint64_t)psbuf->st_ex_ino;
> > >    }
> > >    file_index = ((psbuf->st_ex_ino) & UINT32_MAX); /* FileIndexLow */
> > >    file_index |= ((uint64_t)((psbuf->st_ex_dev) & UINT32_MAX)) << 32; /* FileIndexHigh */
> > >    return file_index;
> > > }
> > 
> > Which Samba version introduced this behaviour?  Originally, way back
> > when Samba 3.0.28 was new, the inode numbers were always mangled to be
> > 64 bit numbers, AFAIK.  The code in Cygwin which doesn't trust 32 bit
> > inode numbers on remote drives is there for ages, at least since 2007.
> > 
> > Fortunately we have an interface which allows to fetch the Samba version
> > number from the server since Samba 3.0.28a.  So, if we know which Samba
> > version started to return the real 32 bit inode number, we can adapt.
> > [...]
> > inline bool
> > path_conv::isgood_inode (__ino64_t ino) const
> > {
> >   /* We can't trust remote inode numbers of only 32 bit.  That means,
> >      remote NT4 NTFS, as well as shares of Samba version < 3.0.
> >      The known exception are SFU NFS shares, which return the valid 32 bit
> >      inode number from the remote file system unchanged. */
> >   return hasgood_inode () && (ino > UINT32_MAX || !isremote () || fs_is_nfs ());
> > }
> 
> The get_FileIndex() code has been there since at least 3.6.x, but
> I'll try and track down when it was first introduced.

That would be nice.  For now, assuming the get_FileIndex has been
introduced with 3.6.0, I'd go with this new implementation, stretched
out and better comments for readability:

inline bool
path_conv::isgood_inode (__ino64_t ino) const
{ 
  /* If the FS doesn't support nonambiguous inode numbers anyway, bail out
     immediately. */
  if (!hasgood_inode ())
    return false;
  /* If the inode numbers are 64 bit numbers or if it's a local FS, they
     are to be trusted. */
  if (ino > UINT32_MAX || !isremote ())
    return true;
  /* The inode numbers returned from a remote NT4 NTFS are ephemeral
     32 bit numbers. */
  if (fs_is_ntfs ())
    return false;
  /* Samba versions since 3.x.x return the real inode numbers, unless the file
     is not on the same device as the root of the share, in which case Samba
     returns a mangled inode number which is a 64 bit number again.  See the
     get_FileIndex function in the Samba sources. */
  if (fs_is_samba () && fs.samba_version () >= 0x03060000)
    return true;
  /* SFU NFS just returns the actual inode number. */
  if (fs_is_nfs ())
    return true;
  /* Otherwise, don't trust the inode numbers. */
  return false;
} 


What do you say?

Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019