Previous  |  Next  >  
Product: File System Guides   
Manual: File System 4.1 Administrator's Guide   

File Change Log Programmatic Interface

The standard system calls open(2), lseek(2), read(2) and close(2) can be used on the FCL file at mount_point/lost+found/changelog. Only one programmatic interface is exposed through libvxfsutil, the vxfs_fcl_sync API (see the vxfs_fcl_sync(3) manual page). The prototype is available at /opt/VRTSfssdk/4.1.00.0/include/vxfsutil.h.

The following sample code fragment reads the FCL superblock, checks that the state of the FCL is VX_FCLS_ON, issues a call to vxfs_fcl_sync to obtain a finishing offset to read to, determines the first valid offset in the FCL file, then reads the entries in 8K chunks from this offset. The section process fcl entries is what an application developer must supply to process the entries in the FCL.


 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/fcntl.h>
 #include <errno.h>
 #include <fcl.h>
 #include <vxfsutil.h>

 #define FCL_READSZ 8192

 char* fclname = "/mnt/lost+found/changelog";

 int
 read_fcl(fclname)
    char* fclname;
 {
    struct fcl_sb fclsb;
    uint64_t off, lastoff;
    size_t size;
    char buf[FCL_READSZ], *bufp = buf;
    int fd;
    int err = 0;

    if ((fd = open(fclname, O_RDONLY)) < 0) {
          return ENOENT;
    }
    if ((off = lseek(fd, 0, SEEK_SET)) != 0) {
          close(fd);
          return EIO;
    }
    size = read(fd, &fclsb, sizeof (struct fcl_sb));
    if (size < 0) {
          close(fd);
          return EIO;
    }
    if (fclsb.fc_state == VX_FCLS_OFF) {
          close(fd);
          return 0;
    }
    if (err = vxfs_fcl_sync(fclname, &lastoff)) {
          close(fd);
          return err;
    }
    if ((off = lseek(fd, fclsb.fc_foff, SEEK_SET)) !=
       fclsb.fc_foff) {
          close(fd);
          return EIO;
    }
    while (off < lastoff) {
          if ((size = read(fd, bufp, FCL_READSZ)) <= 0) {
                close(fd);
                return errno;
          }
          /* process fcl entries */
          off += size;
    }
    close(fd);
    return 0;
 }
 ^ Return to Top Previous  |  Next  >  
Product: File System Guides  
Manual: File System 4.1 Administrator's Guide  
VERITAS Software Corporation
www.veritas.com