delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/03/11/11:54:41

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX19k+Q1/uS9k4ajejxlVRxcm8PSM9DKZvW2FA5Vnlr
ZWLIPV6AsuohYf
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: Value stored in cache_blksize if _is_remote_drive fails
Date: Sun, 11 Mar 2012 16:50:53 +0100
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <201203111650.53344.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

Please inspect the following code snippet taken from _get_cached_blksize()
of xstat.c:

-- code start --
  if (!cache_blksize[d])
  {
    if (_is_remote_drive(d))  /* A = 0, B = 1, C = 2,  etc. */
    {
      /* Default remote drives to 4K block size, to improve performance.
       *
       * Also the size returned by statfs() may not be correct. Testing
       * against files shared by Samba 2.0.10 on Linux kernel 2.2.19
       * returned a 32K block size, even though the ext2 filesystem
       * holding the share share had a 4K block size. */
      cache_blksize[d] = 4096;
    }
    else
    {
      /* No entry => retrieve cluster size */
      if (statfs(path, &sbuf) != 0)
      {
        /* Failed, pass error through */
        return -1;
      }

      cache_blksize[d] = sbuf.f_bsize;
    }
  }
-- code end --


If _is_remote_drive returns with a value different from 0 then cache_blksize[d]
is set to 4096.  The issue is that _is_remote_drive may return with 1 if d is a
remote drive but also it may return with -1 if the function fails for drive
number d.  In both cases cache_blksize[d] = 4096.  The question arises if this
is a bug or a feature?  Drive "d" does not exist but a valid block size is 
assigned to cache_blksize[d] at the same time the errno (= ENODEV) set by
_is_remote_drive may get lost in future operations.


Regards,
Juan M. Guerrero

- Raw text -


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