After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 127193 - statfs struct members not valid on Solaris
statfs struct members not valid on Solaris
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Build
cvs (head)
Other opensolaris
: Normal critical
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
: 128141 128628 (view as bug list)
Depends on:
Blocks: 97789
 
 
Reported: 2003-11-17 14:50 UTC by Damien Carbery
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.5/2.6


Attachments
Solaris-specific references to statfs structure members. (1.17 KB, patch)
2003-11-17 15:40 UTC, Damien Carbery
none Details | Review
alternative patch (719 bytes, patch)
2003-11-17 19:33 UTC, radu
none Details | Review
Updated patch (973 bytes, patch)
2003-11-26 12:20 UTC, padraig.obriain
none Details | Review
Linux only test for ncpfs patch (1.16 KB, patch)
2003-11-27 01:16 UTC, radu
none Details | Review

Description Damien Carbery 2003-11-17 14:50:14 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)."
Comment 1 Christophe Fergeau 2003-11-17 14:58:06 UTC
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) ?
Comment 2 Damien Carbery 2003-11-17 15:40:39 UTC
Created attachment 21536 [details] [review]
Solaris-specific references to statfs structure members.
Comment 3 radu 2003-11-17 19:32:19 UTC
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 ();
    }
}
Comment 4 radu 2003-11-17 19:33:19 UTC
Created attachment 21550 [details] [review]
alternative patch
Comment 5 padraig.obriain 2003-11-26 12:20:14 UTC
Created attachment 21825 [details] [review]
Updated patch
Comment 6 padraig.obriain 2003-11-26 12:21:25 UTC
Committed updated patch to CVS HEAD.
Comment 7 radu 2003-11-27 01:15:06 UTC
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.
Comment 8 radu 2003-11-27 01:16:10 UTC
Created attachment 21852 [details] [review]
Linux only test for ncpfs patch
Comment 9 Christophe Fergeau 2003-11-28 21:42:40 UTC
*** Bug 128141 has been marked as a duplicate of this bug. ***
Comment 10 Christophe Fergeau 2003-12-05 23:16:03 UTC
*** Bug 128628 has been marked as a duplicate of this bug. ***
Comment 11 devsk 2004-03-01 05:54:57 UTC
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?
Comment 12 devsk 2004-03-01 05:55:47 UTC
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?
Comment 13 devsk 2004-03-06 01:33:24 UTC
Any updates for 2.4.2 which have this fixed?
Comment 14 Christophe Fergeau 2004-03-07 20:26:31 UTC
See bug #136468 for a patch for that for 2.4