GNOME Bugzilla – Bug 127193
statfs struct members not valid on Solaris
Last modified: 2004-12-22 21:47:04 UTC
The f_type member of the statfs struct is called 'f_fstyp' on Solaris. Also, the statfs struct is in sys/statfs.h. Finally, according to sys/statfs.h the function has been replaced by statvfs and will soon be removed from the system. The attached patch includes sys/statfs.h and changed f_type to f_fstyp, both inside '#ifdef __sun'. Also, statfs() requires 4 parameters on Solaris ('missing' two are ints). I passed 0 for each because I could not find a man page on statfs. For Solaris it might be better to return from the function or to call statvfs (again). Makefile and compiler output: cc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -mt -DORBIT2=1 -I/opt/gnome-2.4/include/glib-2.0 -I/opt/gnome-2.4/lib/glib-2.0/include -I/opt/gnome-2.4/include/gconf/2 -I/opt/gnome-2.4/include/orbit-2.0 -I/opt/gnome-2.4/include/bonobo-activation-2.0 -I/opt/gnome-2.4/include/libbonobo-2.0 -I/opt/gnome-2.4/include/libxml2 -DORBIT2=1 -I/opt/gnome-2.4/include/libbonobo-2.0 -I/opt/gnome-2.4/include/glib-2.0 -I/opt/gnome-2.4/lib/glib-2.0/include -I/opt/gnome-2.4/include/orbit-2.0 -I/opt/gnome-2.4/include/bonobo-activation-2.0 -D_FILE_OFFSET_BITS=64 -D_BSD_SOURCE -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -DG_DISABLE_DEPRECATED -DDATADIR=\"/opt/gnome-2.4/share\" -DLIBDIR=\"/opt/gnome-2.4/lib\" -DPREFIX=\"/opt/gnome-2.4\" -DGNOMEVFS_LOCALEDIR=\"/opt/gnome-2.4/share/locale\" -DSYSCONFDIR=\"/opt/gnome-2.4/etc\" -DG_LOG_DOMAIN=\"libgnomevfs\" -I/opt/gnome-2.4/include -g -I/opt/gnome-2.4/include -c gnome-vfs-utils.c -KPIC -DPIC -o .libs/gnome-vfs-utils.o "gnome-vfs-utils.c", line 593: warning: assignment type mismatch: pointer to unsigned char "=" pointer to char "gnome-vfs-utils.c", line 595: warning: argument #1 is incompatible with prototype: prototype: pointer to const char : "gnome-vfs-utils.c", line 422 argument : pointer to unsigned char "gnome-vfs-utils.c", line 813: incomplete struct/union/enum statfs: statfs_buffer2 "gnome-vfs-utils.c", line 814: warning: implicit function declaration: statfs "gnome-vfs-utils.c", line 822: undefined struct/union member: f_type "gnome-vfs-utils.c", line 1066: cannot recover from previous errors cc: acomp failed for gnome-vfs-utils.c make[3]: *** [gnome-vfs-utils.lo] Error 1 ***** sys/statfs.h ***** /* * Structure returned by statfs(2) and fstatfs(2). * This structure and associated system calls have been replaced * by statvfs(2) and fstatvfs(2) and will be removed from the system * in a near-future release. */ See also: http://docs.sun.com/db/doc/805-4037/6j3r4orqb?q=statfs&a=view "statfs Gets file system statistics about mounted file systems. Calls statvfs(2)."
This is a consequence of committing the patch from #97789 The problem with statvfs is that it doesn't have a field indicating the file system type, that's why statfs is used. Any idea how this could be done on Solaris (if it supports ncpfs at all) ?
Created attachment 21536 [details] [review] Solaris-specific references to statfs structure members.
I don't know if ncpfs can be compiled and used on Solaris, but on Solaris the statvfs structure has a member, f_basetype, which is a string with the type of the filesystem. For Solaris the additional statfs is not needed and I believe that Damien's patch would need additional code to interpret the f_fstyp field. As an alternative I would like to propose a different patch. The latest version of gnome-vfs I have is the one from Fedora, 2.4.1, but I tried to make it apply to HEAD. It's not included in this patch, but please note that a "g_free (unescaped_path)" is needed after the code that checks for ncpfs. While making this patch it occured to me that a better alternative could be the following code. Unfortunately I don't know how I could get linked filesystem_type() from modules/fstype.c, because modules is built later, after libgnomevfs. /* ncpfs does not know the amount of available and free space */ if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0) { struct stat statbuf; if (stat (unescaped_path, &statbuf) == 0) { char *type = filesystem_type (unescaped_path, unescaped_path, &statbuf); if (strcmp (type, "ncpfs") == 0) { g_free (unescaped_path); return GNOME_VFS_ERROR_NOT_SUPPORTED; } } else { g_free (unescaped_path); return gnome_vfs_result_from_errno (); } }
Created attachment 21550 [details] [review] alternative patch
Created attachment 21825 [details] [review] Updated patch
Committed updated patch to CVS HEAD.
With the commited patch, if the OS is neither Solaris nor Linux and both statfs_buffer.f_bavail and statfs_buffer.f_bfree are zero, then the function returns GNOME_VFS_ERROR_NOT_SUPPORTED without having tested that the file sysyem is ncpfs. I propose to test for ncpfs only on Linux because: - I'm 99% sure that the Linux ncpfs has not been ported to Solaris or other OSes. Maybe it has been ported to FreeBSD but I suppose that the usage is very low and a BSD developer may send a patch in the future if needed. - ncpfs will probably die slowly now that latest Netware versions can export its filesystems through NFS. This Linux only patch will also fix the memory leak.
Created attachment 21852 [details] [review] Linux only test for ncpfs patch
*** Bug 128141 has been marked as a duplicate of this bug. ***
*** Bug 128628 has been marked as a duplicate of this bug. ***
This compile failure happens in GNOME-VFS 2.4.2 as well. Is there a 2.4 release of this package which has this fix?
Any updates for 2.4.2 which have this fixed?
See bug #136468 for a patch for that for 2.4