Inode Scanning

The inode module provides methods for performing inode scans and for determining properties of inodes.

Also refer to the arcapix.fs.gpfs.clib.utils.inode_iterator convenience function.

Note

These objects require root permission to create

Description

arcapix.fs.gpfs.clib.inode.close_inodescan(inodescan iscan)

Close an inode scan.

This is important for making sure the pointers are cleaned up once they’re no longer needed.

Parameters:iscan (inodescan) – an open inodescan object
arcapix.fs.gpfs.clib.inode.get_flags_strings(flags)

Get strings for flags integer.

Used to convert flags integer from an inode scan as part of the iattr structure.

Return type:list of str
arcapix.fs.gpfs.clib.inode.get_pcacheflags_strings(pcacheflags)

Get strings for pcache flags integer.

Used to convert pcacheflags integer from an inode scan as part of the iattr structure.

Return type:list of str
arcapix.fs.gpfs.clib.inode.get_winflags_strings(int winflags)

Get strings for Windows flags integer.

Used to convert winflags integer from an inode scan as part of the iattr structure.

Return type:list of str
arcapix.fs.gpfs.clib.inode.get_xperm_strings(xperm)

Get strings for extended attributes integer.

Used to convert xperm integer from an inode scan as part of the iattr structure.

Return type:list of str
arcapix.fs.gpfs.clib.inode.igetfilesetname(int fsetid, inodescan iscan)

Get fileset name from a numerical fileset name.

Used to lookup fileset from id returned by an inode scan as part of the iattr structure.

Parameters:
  • fsetid (int) – numerical fileset id
  • iscan (inodescan) – inodescan object used to return the iattr that the fileset id came from
Return type:

unicode

arcapix.fs.gpfs.clib.inode.igetstoragepool(int poolid, inodescan iscan)

Get storagepool name from a numerical pool id.

Used to lookup pool name from id returned by an inode scan as part of the iattr structure.

Parameters:
  • poolid (int) – numerical pool id
  • iscan (inodescan) – inodescan object used to return the iattr that the pool id came from
Return type:

unicode

class arcapix.fs.gpfs.clib.inode.inodescan

The inode scan object acts as a wrapper for iscan_t pointer.

arcapix.fs.gpfs.clib.inode.next_inode(inodescan iscan, gpfs_ino64_t termIno=0)

Get the next inode from the scan.

Can be used to iterate over inodes in the filesystem

>>> for ino in iter(lambda: next_inode(iscan), None):
...     # do stuff
Parameters:
  • iscan (inodescan) – an open inodescan object
  • termIno (int) – inode to stop scanning at. If not specified, all inode in the filesystem will be scanned.
Returns:

an iattr structure with information about the next inode

Return type:

iattr

arcapix.fs.gpfs.clib.inode.open_inodescan(fssnap_handle handle, fssnap_id previd=None)

Open an inode scan.

Parameters:
  • fssnap (fssnap_handle) – An fssnap_handle identifying the Filesystem or snapshot to be scanned
  • previd (fssnap_id`) – An fssnap_id identifying a previous snapshot If provided, only files that have changed since the specified snapshot will be returned Pass None to return all user files from fssnap
arcapix.fs.gpfs.clib.inode.seek_inode(inodescan iscan, gpfs_ino64_t ino)

Seek to the inode with number greater than or equal to ino

You have to call next_inode() to retrieve the requested inode

Parameters:
  • iscan (inodescan) – an open inodescan object
  • ino (int) – Inode number to seek
Returns:

nothing

arcapix.fs.gpfs.clib.inode.stat_inode(inodescan iscan, gpfs_ino64_t ino, gpfs_ino64_t termIno=0)

Get the inode with number equal to ino

Raises:KeyError if an inode isn’t found with the specified number

Note: this will seek to the requested inode number even if that inode isn’t found - e.g.

>>> next_inode(iscan).ia_inode
3
>>> stat_inode(iscan, 100).ia_inode
KeyError(Inode '100' not found)
>>> next_inode(iscan).ia_inode
103
Parameters:
  • iscan (inodescan) – an open inodescan object
  • ino (int) – Inode number to get
  • termIno (int) – inode to stop scanning at. If not specified, all inode in the filesystem will be scanned.
Returns:

an iattr structure with information about the next inode

Return type:

iattr

Examples

List attributes for all inodes in a Filesystem

>>> from arcapix.fs.gpfs.clib.inode import open_inodescan, next_inode, close_inodescan
>>> from arcapix.fs.gpfs.clib.fssnap import get_fssnaphandle_by_name
>>>
>>> # get fssnap_handle for filesystem 'mmfs1'
... fs = get_fssnaphandle_by_name('mmfs1')
>>>
>>> # open an inodescan
... iscan = open_inodescan(fs)
>>>
>>> # iterate over inodes
... for i in iter(lambda: next_inode(iscan), None):
...     # print formatted results
...     print "%010d/%010d\t%010u\t%010u\n" % (i.ia_inode, i.ia_gen, i.ia_mtime, i.ia_ctime)
'0000000003/0000000001   1462870041  1462870041'
'0000000042/0000065538   1464784185  1448989426'
'0000000043/0000065538   1464784185  1448989427'
'0000000044/0000065538   1464784185  1448989427'
'0000004038/0779965892   1459948505  1459948505'
'...'

>>> # remember to close iscan
... close_inodescan(iscan)