Symantec logo

File Change Log programmatic interface

VxFS 5.0 provides an enhanced API to simplify reading and parsing the FCL in two ways:

Simplified reading 

The API simplifies user tasks by reducing additional code needed to parse FCL entries. In 4.1, to obtain event information such as a remove or link, the user was required to write additional code to get the name of the removed or linked file. In 5.0, the API allows the user to directly read an assembled record. The API also allows the user to specify a filter to indicate a subset of the event records of interest. 

Backward compatibility 

Providing API access for the FCL feature allows backward compatibility for applications. The API allows applications to parse the FCL file independent of the FCL layout changes. Even if the hidden disk layout of the FCL changes, the API automatically translates the returned data to match the expected output record. As a result, the user does not need to modify or re-compile the application due to changes in the on-disk FCL layout. 

See Reverse path name lookup.

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, off_t, uint64_t)) !=

uint64_t) {

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;

}