Technical article 100802

Using sysfs(S) to check for S51K filesystem fails on SCO OpenServer 5.

OpenServer 5.0.0

Written · Last revised

Problem

I am trying to use sysfs(S) to check for the existence of the S51K filesystem. This fails with a return value of -1 although the same routine used to work in previous releases of the development system. This works with other filesystem types such as HTFS, for example:

#include <sys/fstyp.h>
#include <sys/fsid.h>
<...>

fstyp = sysfs (GETFSIND, "HTFS") ; /* This works */

fstyp = sysfs (GETFSIND, "S51K") ; /* This fails by returning -1 */

<...>

Cause

The sysfs() system call is the system interface which allows the
fsinfo[] array to be queried.  It is used mainly by high level,
generic filesystem code to find an index for a particular filesystem.
This is a way to incorporate filesystem specific code into the
program: these routine addresses are stored at the same index in
the fstypsw[] array.
There is a problem with this routine in SCO OpenServer
Development System Release 5.0.  Since the HTFS filesystem
is handled by the same driver as the s51K filesystem, the
routine should work in both cases, however it does not appear
to recognize the S51K filesystem.

This has been reported to SCO Engineering.

Solution

The statvfs(S) routine will provide this functionality, as will other routines such as statfs(S), fstatfs(S), fstatvfs(S) and fstyp(ADM).

This example checks two files on an SCO OpenServer 5 system and reports the filesystem type using statvfs(S):

/************************************************************************/
#include <stdio.h>
#include <sys/statvfs.h>
#include <sys/types.h>

main(argc, argv) int argc; char **argv; { struct statvfs *buffer=NULL; int statvfs_return = 0;

/* Check statvfs */ buffer=(struct statvfs *)malloc(sizeof(struct statvfs)); if ( statvfs ("/.profile", buffer) == -1) { printf("statvfs failed\n"); exit(1); } else printf("filesystem type is %s \n", buffer -> f_basetype);

if ( statvfs ("/unix", buffer) == -1)

{ printf("statvfs failed\n"); exit(1); } else printf("filesystem type is %s \n", buffer -> f_basetype);

}

From the Xinuos technical article database, record 100802. Reproduced with permission. The original is at www.sco.com/ta/100802, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.