*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> fsctl (2)              
Title
Content
Arch
Section
 

Contents


 fsctl(2)                                                           fsctl(2)




 NAME    [Toc]    [Back]
      fsctl - file system control

 SYNOPSIS    [Toc]    [Back]
      #include <sys/unistd.h>

      int fsctl(
           int fildes,
           int command,
           void *outbuf,
           size_t outlen
      );

 DESCRIPTION    [Toc]    [Back]
      fsctl() provides access to file-system-specific information.  fildes
      is an open file descriptor for a file in the file system of interest.
      The possible values for command depend on the type of file system.
      Currently, defined commands exist only for the CDFS file system (see
      sys/cdfsdir.h).

      outbuf is a pointer to the data area in which data is returned from
      the file system.  outlen gives the length of the data area pointed to
      by outbuf.

      The CDFS commands are:

           CDFS_DIR_REC      Returns the directory record for the file or
                             directory indicated by fildes.  The record is
                             returned in a structure of type cddir, defined
                             in <sys/cdfsdir.h>.

           CDFS_XAR          Returns the extended attribute record, if any,
                             for the file or directory indicated by fildes.
                             Because the size of an extended attribute
                             record varies, be sure outbuf points to a data
                             area of sufficient size.  To find the necessary
                             size, do the following:

                             1.   Use statfs(2).  to get the logical block
                                  size of the CDFS volume.

                             2.   Use an fsctl() call with the CDFS_DIR_REC
                                  command to get the extended attribute
                                  record size (in blocks) for the file or
                                  directory of interest.  The mincdd_xar_len
                                  field in the returned structure contains
                                  the size of the extended attribute record
                                  in logical blocks.  (If this field is
                                  zero, the file or directory has no
                                  extended attribute record.)




 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 fsctl(2)                                                           fsctl(2)




                             3.   Multiply mincdd_xar_len by the logical
                                  block size obtained in step 1 to get the
                                  total space needed.

                             4.   Once you get the extended attribute
                                  record, cast outbuf into a pointer to a
                                  structure of type cdxar_iso (defined in
                                  <sys/cdfsdir.h>).  This enables you to
                                  access those fields that are common to all
                                  extended attribute records.  (See EXAMPLES
                                  below for an example of this process.)

                                  If the extended attribute record contains
                                  additional system use or application use
                                  data, that data will have to be accessed
                                  manually.

           CDFS_AFID         Returns the abstract file identifier for the
                             primary volume whose root directory is
                             specified by fildes, terminated with a NULL
                             character.  Note that the constant CDMAXNAMLEN
                             defined in <sys/cdfsdir.h> gives the maximum
                             length a file identifier can have.  Thus,
                             CDMAXNAMLEN + 1 can be used for outlen and the
                             size of outbuf.

           CDFS_BFID         Returns the bibliographic file identifier for
                             the primary volume whose root directory is
                             specified by fildes, terminated with a NULL
                             character.  CDMAXNAMLEN + 1 can be used for the
                             value of outlen and the size of outbuf.

           CDFS_CFID         Returns the copyright file identifier for the
                             primary volume whose root directory is
                             specified by fildes, terminated with a NULL
                             character.  CDMAXNAMLEN + 1 can be used for the
                             value of outlen and the size of outbuf.

           CDFS_VOL_ID       Returns the volume ID for the primary volume
                             specified by fildes, terminated with a NULL
                             character.  The maximum size of the volume ID
                             is 32 bytes, so a length of 33 can be used for
                             outlen and the size of utbuf.

           CDFS_VOL_SET_ID   Returns the volume set ID for the primary
                             volume specified by fildes, terminated with a
                             NULL character.  The maximum size of the volume
                             set ID is 128 bytes, so a length of 129 can be
                             used for outlen and the size of outbuf.





 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003






 fsctl(2)                                                           fsctl(2)




 EXAMPLES    [Toc]    [Back]
      The following code fragment gets the extended attribute record for a
      file on a CDFS volume.  The filename is passed in as the first
      argument to the routine.  Note that error checking is omitted for
      brevity.

           #include <sys/types.h>
           #include <sys/vfs.h>
           #include <fcntl.h>
           #include <sys/cdfsdir.h>

           main(argc, argv)
           int argc;
           char *argv[];
           {
              int fildes, size = 0;
              char *malloc(), *outbuf;
              struct statfs buf;
              struct cddir cdrec;
              struct cdxar_iso *xar;
                      .
                      .
                      .
              statfs(argv[1], &buf);   /* get logical block size */

              fildes = open(argv[1], O_RDONLY);  /* open file arg */

              /* get directory record for file arg */
              fsctl(fildes, CDFS_DIR_REC, &cdrec, sizeof(cdrec));

              size = buf.f_bsize * cdrec.cdd_min.mincdd_xar_len;   /* compute size */

              if(size) {   /* if size != 0 then there is an xar */
              outbuf = malloc(size);   /* malloc sufficient memory */

              fsctl(fildes, CDFS_XAR, outbuf, size);  /* get xar */

              xar = (struct cdxar_iso *)outbuf;  /* cast outbuf to access fields */
                      .
                      .
                      .
              }
                 .
                 .
                 .
           }

 RETURN VALUE    [Toc]    [Back]
      fsctl() returns the number of bytes read if successful.  If an error
      occurs, -1 is returned and errno is set to indicate the error.




 Hewlett-Packard Company            - 3 -   HP-UX 11i Version 2: August 2003






 fsctl(2)                                                           fsctl(2)




 ERRORS    [Toc]    [Back]
      fsctl() fails if any of the following conditions are encountered:

           [EBADF]        fildes is not a valid open file descriptor.

           [EFAULT]       outbuf points to an invalid address.

           [ENOENT]       The requested information does not exist.

           [EINVAL]       command is not a valid command.

           [EINVAL]       fildes does not refer to a CDFS file system.

 SEE ALSO    [Toc]    [Back]
      statfs(2), cdfs(4), cdfsdir(4), cdnode(4), cdrom(4).


 Hewlett-Packard Company            - 4 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
vxfsio HP-UX VxFS file system control functions
acl FreeBSD virtual file system access control lists
delta Tru64 Saves editing changes in a Source Code Control System (SCCS) file
rmdel Tru64 Removes a delta from a Source Code Control System (SCCS) file
sccsdiff Tru64 Compares two versions of a Source Code Control System (SCCS) file
prs Tru64 Displays key information in a Source Code Control System (SCCS) file
get Tru64 Creates a specified version of a Source Code Control System (SCCS) file
sact Tru64 Displays current Source Code Control System (SCCS) file editing status
mount_nullfs FreeBSD mount a loopback file system sub-tree; demonstrate the use of a null file system layer
openlog Tru64 Control system log
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service