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

iattr struct

The iattr struct, returned by next_inode() and stat_inode(), has the following fields

ia_mode              # access mode
ia_uid               # owner uid
ia_gid               # owner gid
ia_inode             # file inode number
ia_gen               # inode generation number
ia_nlink             # number of links
ia_size              # file size in bytes
ia_blocks            # 512 byte blocks of disk held by file
ia_atime             # time of last access
ia_winflags          # windows flags - can be converted with 'get_winflags_strings'
ia_mtime             # time of last data modification
ia_flags             # flags - can be converted with 'get_flags_strings'
ia_repl_data         # data replication factor
ia_repl_data_max     # data replication max factor
ia_repl_meta         # meta data replication factor
ia_repl_meta_max     # meta data replication max factor
ia_ctime             # time of last status change
ia_blocksize         # preferred block size for io
ia_createtime        # creation time
ia_xperm             # extended attributes - can be converted with 'get_xperms_strings'
ia_dev               # id of device containing file
ia_rdev              # device id (if special file)
ia_pcacheflags       # pcache inode bits - can be converted with 'get_pcacheflags_strings'
ia_modsnapid         # snapshot id of last modification
ia_filesetid         # fileset ID - can be converted to name with 'igetfilesetname'
ia_datapoolid        # storage pool ID for data - can be converted to name with 'igetstoragepool'
ia_inode_space_mask  # inode space mask of this file system
                     # This value is saved in the iattr structure
                     #    during backup and used during restore

Time fields ia_atime, ia_mtime, ia_ctime, and ia_changetime are type float. All other fields are of type int.

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(unsigned int 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(unsigned 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(unsigned 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(unsigned 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.

max_inode

Maximum inode number in the filesystem or snapshot being scanned.

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)