sofs19  0.1
FUSE based file system
direntries

Functions to manage directory entries. More...

Functions

uint32_t soTraversePath (char *path)
 Get the inode associated to a given path. More...
 
uint32_t soGetDirEntry (int pih, const char *name)
 Get the inode associated to a given name. More...
 
void soAddDirEntry (int pih, const char *name, uint32_t cin)
 Add a new entry to the parent directory. More...
 
uint32_t soDeleteDirEntry (int pih, const char *name)
 Delete an entry from a parent directory. More...
 
void soRenameDirEntry (int pih, const char *name, const char *newName)
 Rename an entry of a directory. More...
 
bool soCheckDirEmpty (int ih)
 Check directory emptiness. More...
 

Detailed Description

Functions to manage directory entries.

Remarks
In case an error occurs, every function throws an SOException

Function Documentation

◆ soTraversePath()

uint32_t sofs19::soTraversePath ( char *  path)

Get the inode associated to a given path.

The directory hierarchy of the file system is traversed to find an entry whose name is the rightmost component of the given path

Parameters
[in]paththe path to be traversed
Remarks
  • if path is not absolute, error EINVAL is thrown;
  • if one of the path components, with the exception of the rightmost one, is not a directory, error ENODIR is thrown;
  • if the process that calls the operation does not have traverse (x) permission on all the components of the path, with exception of the rightmost one, error EACCES is thrown;
  • it is assumed that path does not contain symbolic links;
  • when calling a function of any layer, the version with prefix so is used.
Returns
the corresponding inode number

◆ soGetDirEntry()

uint32_t sofs19::soGetDirEntry ( int  pih,
const char *  name 
)

Get the inode associated to a given name.

The directory contents, seen as an array of directory entries, is parsed to find an entry whose name is the given one.

Parameters
[in]pihinode handler of the parent directory
[in]namethe name of the entry to be searched for
Remarks
  • Assumes pih is a valid inode handler of a directory
  • Error EINVAL is thrown if name is not a base name, that is, if it contains the character '/'.
  • when calling a function of any layer, the version with prefix so is used.
Returns
the corresponding inode number (even if it is NullReference)

◆ soAddDirEntry()

void sofs19::soAddDirEntry ( int  pih,
const char *  name,
uint32_t  cin 
)

Add a new entry to the parent directory.

A direntry is added connecting the parent inode to the child inode.

Parameters
[in]pihinode handler of the parent inode
[in]namethe name of the entry to be created
[in]cininode number of the entry to be created
Remarks
  • Assumes pih is a valid inode handler of a directory where the user has write access
  • Assumes cin is a valid inode number
  • Error EEXIST is thrown if name already exists
  • The lnkcnt of the child inode is not changed by this function.
  • when calling a function of any layer, the version with prefix so is used.

◆ soDeleteDirEntry()

uint32_t sofs19::soDeleteDirEntry ( int  pih,
const char *  name 
)

Delete an entry from a parent directory.

A direntry associated from the given directory is deleted.

Parameters
[in]pihinode handler of the parent inode
[in]namename of the entry
Remarks
  • Assumes pih is a valid inode handler of a directory where the user has write access
  • Error ENOENT is thrown if name does not exist
  • The lnkcnt of the child inode is not changed by this function.
  • when calling a function of any layer, the version with prefix so is used.
Returns
the inode number of the deleted entry

◆ soRenameDirEntry()

void sofs19::soRenameDirEntry ( int  pih,
const char *  name,
const char *  newName 
)

Rename an entry of a directory.

A direntry associated from the given directory is renamed.

Parameters
[in]pihinode handler of the parent inode
[in]namecurrent name of the entry
[in]newNamenew name for the entry
Remarks
  • Assumes pih is a valid inode handler of a directory where the user has write access
  • Error ENOENT is thrown if name does not exist
  • when calling a function of any layer, the version with prefix so is used.

◆ soCheckDirEmpty()

bool sofs19::soCheckDirEmpty ( int  ih)

Check directory emptiness.

The directory is traversed to verified if the only existing entries are "." and "..".

Parameters
[in]ihhandler of the inode to be checked
Remarks
  • Assumes ih is a valid inode handler of a directory
  • when calling a function of any layer, the version with prefix so is used.