Bug 7707 - stat() fails if cifs-fs is mounted without noserverino option
Summary: stat() fails if cifs-fs is mounted without noserverino option
Status: RESOLVED INVALID
Alias: None
Product: CifsVFS
Classification: Unclassified
Component: kernel fs (show other bugs)
Version: 2.6
Hardware: Other Linux
: P3 normal
Target Milestone: ---
Assignee: Jeff Layton
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-01 03:14 UTC by Gerhard Schiller
Modified: 2010-10-07 10:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Schiller 2010-10-01 03:14:17 UTC
When mounting a windows share with mount.cifs without the "noserverino" option, a call to stat() will fail.


mount.cifs version: 4.6 - I compiled it myself from "cifs-utils-4.5" src package as I had to apply a patch to make the "credentials" option work.

kernel: 2.6.34.7

How to reproduce:
Mount a windows share using an fstab line like this:
//10.110.13.172/intranet$ /mnt/idefix/intranet cifs credentials=/etc/samba.credentials_for_idefix_intranet,rw,uid=gerhard,gid=users,dir_mode=0755,file_mode=0664 0 0

Compile and run the test program with the path to a file on the share as argument:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>

main(int argc, char **argv)
{
  struct stat statbuf;
  
  if(stat(argv[1], &statbuf) == 0)
    printf("st_ino = %d, st_mode = 0%o, st_size = %d\n", statbuf.st_ino, statbuf.st_mode, statbuf.st_size);
  else{
	fprintf(stderr, "errno:%d, ", errno);
        perror("stat");
  }
  
  return 0;
}

It will fail with:
errno:75, stat: Value too large for defined data type.

Now umount the share an mount it again with the noserverino option using an fstab line like this:
//10.110.13.172/intranet$ /mnt/idefix/intranet cifs noserverino,credentials=/etc/samba.credentials_for_idefix_intranet,rw,uid=gerhard,gid=users,dir_mode=0755,file_mode=0664 0 0

Run the test programm again, and it will display some parts of the stat structure.

What else:
My "hardware" is actually a virtual machine, running under VM-Player.
I have an other (older) virtual machine on my hard disk, which did not require the noserverino option. So I copied my test program - the binary - to that other machine and it was able to "stat" the share.

This environment:

mount.cifs version: 1.10-3.0.32-0.2-2210-SUSE-SL10.3
Kernel 2.6.22.19

Compiling the source code of the test on the older machine and running it on the machine where I encountered the problem gave the same results: failure to "stat" without noserverino.

Therefore I believe, the problem is within the cifs package and not with in stat().

The problem and the workaround is documented at:
http://bugs.php.net/bug.php?id=51266

Gerhard Schiller

PS:
As this is my first bug report, please don't be to harsh in your judgment if something it's not perfect...
Comment 1 Jeff Layton 2010-10-05 06:35:34 UTC
This is not a bug in CIFS:

    http://www.suse.de/~aj/linux_lfs.html

Short answer: You need to recompile your test program with 

    -D_FILE_OFFSET_BITS=64

What's happening is that glibc uses the stat64() system call to handle the stat, even with 32-bit non LFS programs. When it gets back a large inode number that doesn't fit in a 32-bit value, it generates EOVERFLOW in userspace and returns that to the program.

noserverino works around this because it tends to generate small values. This is also not likely to be a problem on 64-bit arches.
Comment 2 Gerhard Schiller 2010-10-07 10:01:09 UTC
Not a bug in samba.
KDE3 libraries need to be recompiled with -D_FILE_OFFSET_BITS=64.