Ifile Functions

The ifile module provides methods for opening and reading Filesystem objects by inode number.

These methods could be used to make backups of a Filesystem or iterate selective areas of the Filesystem.

Note

These objects require root permission to create

Description

direntx struct

The direntx struct returned by ireaddir() has the following fields

d_type         # Type (int) - can be converted with 'get_type_string'
d_ino          # File inode number (int)
d_gen          # Generation number for the inode (int)
d_flags        # Flags (int) - can be converted with 'get_flags_strings'
d_name         # File name (str)
arcapix.fs.gpfs.clib.ifile.get_flags_strings(unsigned int flags)

Get strings for direntx flags integer.

Used to convert the d_flags value of direntx as returned by ireaddir`()

Returns

One or more of (JUNCTION, IJUNCTION, ORPHAN, CLONE, NONE)

Return type

list of str

arcapix.fs.gpfs.clib.ifile.get_type_string(int type)

Get the type string for a direntx type integer.

Used to convert the d_type value of direntx as returned by ireaddir`()

Returns

One of (REG, DIR, LNK, DEL, FIFO, CHR, BLK, SOCK, OTHER)

Return type

str

arcapix.fs.gpfs.clib.ifile.iclose(ifile file)

Close an ifile object.

Parameters

file – ifile to close

class arcapix.fs.gpfs.clib.ifile.ifile

The ifile object acts as a wrapper for the gpfs_ifile_t pointer.

arcapix.fs.gpfs.clib.ifile.iopen(fssnap_handle fssnap, gpfs_ino64_t ino, int flags=0)

Open an ifile object for the given inode.

Parameters
  • fsnap (fssnap_handle) – fssnap handle identifying a filesystem or snapshot

  • ino (int) – Inode number of the file object to open

  • flags (int) – flags indicating open mode (default=0, readonly)

Returns

an open ifile object

Return type

ifile

arcapix.fs.gpfs.clib.ifile.iread(ifile file, int buffersize, gpfs_off64_t offset=0)

Read bytes from an open ifile.

Parameters
  • file – ifile to read from. This should correspond to a regular file.

  • buffersize (int) – number of bytes to read

  • offset (int) – offset in file to start reading from (in bytes)

Returns

bytes read

Return type

bytes

arcapix.fs.gpfs.clib.ifile.ireaddir(ifile idir)

Read entries from a directory.

This method can be used to iterate over the file objects in a directory.

>>> for ent in iter(lambda: ireaddir(idir), None):
...     # do stuff
Parameters

idir – ifile to read from. This should correspond to a directory.

Returns

a directory entry representing a file in the directory

Return type

direntx

Get the target of a Symlink by inode number.

Parameters
  • fssnap (fssnap_handle) – Filesystem of snapshot to look in

  • ino (int) – inode number of the symlink to read

Return type

str

Examples