sofs19  0.1
FUSE based file system
main syscalls

Corpus of system calls for evaluation
More...

Functions

int soMknod (const char *path, mode_t mode)
 Create a regular file with size 0. More...
 
int soLink (const char *path, const char *newPath)
 Make a new link to a file. More...
 
int soUnlink (const char *path)
 Delete a link to a file from a directory and possibly the file it refers to from the file system. More...
 
int soMkdir (const char *path, mode_t mode)
 Create a directory. More...
 
int soRmdir (const char *path)
 Remove an existing directory. More...
 
int soRead (const char *path, void *buff, uint32_t count, int32_t pos)
 Read data from an open regular file. More...
 
int soWrite (const char *path, void *buff, uint32_t count, int32_t pos)
 Write data into an open regular file. More...
 
int soRename (const char *path, const char *newPath)
 Change the name or the location of a file in the directory hierarchy of the file system. More...
 
int soTruncate (const char *path, off_t length)
 Truncate a regular file to a specified length. More...
 
int soReaddir (const char *path, void *buff, int32_t pos)
 Read a directory entry from a directory. More...
 
int soSymlink (const char *effPath, const char *path)
 Creates a symbolic link which contains the given path. More...
 
int soReadlink (const char *path, char *buff, size_t size)
 Read the value of a symbolic link. More...
 

Detailed Description

Corpus of system calls for evaluation

Function Documentation

◆ soMknod()

int sofs19::soMknod ( const char *  path,
mode_t  mode 
)

Create a regular file with size 0.

It tries to emulate mknod system call, for regular files.

To get more information, execute in a terminal the command man 2 mknod

Parameters
pathpath to the file
modepermissions to be set
Remarks
  • mode must be a bitwise combination of S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH
  • dirname(path) must exist, be a directory, and write permission on it is required
  • basename(path) must not exist within dirname(path)
  • In case of success
    • An inode is allocated for the new regular file
    • A direntry named basename(path) is added to dirname(path)
    • lnkcnt of the inode associated to basename(path) is updated in order to include the new incoming arc
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soLink()

int sofs19::soLink ( const char *  path,
const char *  newPath 
)

Make a new link to a file.

It tries to emulate link system call.

To get more information, execute in a terminal the command man 2 link

Parameters
pathpath to an existing file
newPathnew path to the same file
Remarks
  • path must represent an existing regular file or symbolic link
  • dirname(newPath) must exist, be a directory, and write permission on it is required
  • basename(newPath) must not exist within dirname(newPath)
  • In case of success
    • A direntry named basename(newPath) is added to dirname(newPath)
    • Field lnkcnt of the inode associated to basename(path) is updated in order to include with the new incoming arc
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soUnlink()

int sofs19::soUnlink ( const char *  path)

Delete a link to a file from a directory and possibly the file it refers to from the file system.

It tries to emulate unlink system call.

To get more information, execute in a terminal the command man 2 unlink

Parameters
pathpath to the file to be deleted
Remarks
  • dirname(path) must exist, be a directory, and write permission on it is required
  • basename(path) must exist within dirname(path) and must be a regular file or symbolic link
  • In case of success
    • The direntry named basename(path) is deleted from dirname(path)
    • lnkcnt of the inode associated to path is updated in order to exclude the deleted incoming arc
    • If after that lnkcnt become zero:
      • All data blocks associated to that inode are freed
      • The inode itself is freed
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soMkdir()

int sofs19::soMkdir ( const char *  path,
mode_t  mode 
)

Create a directory.

It tries to emulate mkdir system call.

To get more information, execute in a terminal the command man 2 mkdir

Parameters
pathpath to the file
modepermissions to be set
Remarks
  • mode must be a bitwise combination of S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH
  • dirname(path) must exist, be a directory, and write permission on it is required
  • base(path) must not exist within dirname(path)
  • In case of success
    • An inode is allocated for the new (child) directory
    • The direntries named . and .. are added to the child directory and, as a consequence, a data block is added, blkcnt is set to 1, and size is set to BlockSize
    • A direntry named basename(path) is added to dirname(path)
    • lnkcnt of parent and child directories are updated in order to include the new incoming arcs
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soRmdir()

int sofs19::soRmdir ( const char *  path)

Remove an existing directory.

It tries to emulate rmdir system call.

To get more information, execute in a terminal the command man 2 rmdir

Parameters
pathpath to the directory to be deleted
Remarks
  • dirname(path) must exist, be a directory, and write permission on it is required
  • basename(path) must exist within dirname(path), be a directory and be empty
  • In case of success
    • All data blocks associated to the deleted (child) directory are freed
    • The inode of the child directory is freed
    • The direntry named basename(path) is deleted from dirname(path)
    • lnkcnt of the inode associated to dirname(path) is updated in order to exclude the deleted incoming arc
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soRead()

int sofs19::soRead ( const char *  path,
void *  buff,
uint32_t  count,
int32_t  pos 
)

Read data from an open regular file.

It tries to emulate read system call.

To get more information, execute in a terminal the command man 2 read

Parameters
pathpath to the file
buffpointer to the buffer where data to be read is to be stored
countnumber of bytes to be read
posstarting [byte] position in the file data continuum where data is to be read from
Remarks
  • The user must have read permission to the inode associated with path
  • In case of success
    • In terms of the disk internal structure, only atime is updated
Returns
the number of bytes read, on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soWrite()

int sofs19::soWrite ( const char *  path,
void *  buff,
uint32_t  count,
int32_t  pos 
)

Write data into an open regular file.

It tries to emulate write system call.

To get more information, execute in a terminal the command man 2 write

Parameters
pathpath to the file
buffpointer to the buffer where data to be written is stored
countnumber of bytes to be written
posstarting [byte] position in the file data continuum where data is to be written into
Remarks
  • The user must have write permission to the inode associated with path
  • In case of success
    • Some data blocks of the associated inode can be updated
    • Some new data blocks can be associated to the inode, in which case blkcnt is updated
    • Field size of the inode can be updated
Returns
the number of bytes written, on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soRename()

int sofs19::soRename ( const char *  path,
const char *  newPath 
)

Change the name or the location of a file in the directory hierarchy of the file system.

It tries to emulate rename system call.

To get more information, execute in a terminal the command man 2 rename

Parameters
pathpath to an existing file
newPathnew path to the same file in replacement of the old one
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soTruncate()

int sofs19::soTruncate ( const char *  path,
off_t  length 
)

Truncate a regular file to a specified length.

It tries to emulate truncate system call.

To get more information, execute in a terminal the command man 2 truncate

Parameters
pathpath to the file
lengthnew size for the regular size
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soReaddir()

int sofs19::soReaddir ( const char *  path,
void *  buff,
int32_t  pos 
)

Read a directory entry from a directory.

It tries to emulate getdents system call, but it reads a single directory entry at a time.
Only the field name is read.

Remarks
The returned value is the number of bytes read from the directory in order to get the next in use directory entry.
The point is that the system (through FUSE) uses the returned value to update file position.

To get more information, execute in a terminal the command man readdir

Parameters
pathpath to the file
buffpointer to the buffer where data to be read is to be stored
posstarting [byte] position in the file data continuum where data is to be read from
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soSymlink()

int sofs19::soSymlink ( const char *  effPath,
const char *  path 
)

Creates a symbolic link which contains the given path.

It tries to emulate symlink system call.

Remarks
The permissions set for the symbolic link should have read (r), write (w) and execution (x) permissions for both user, group and other.

To get more information, execute in a terminal the command man 2 symlink

Parameters
effPathpath to be stored in the symbolic link file
pathpath to the symbolic link to be created
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure

◆ soReadlink()

int sofs19::soReadlink ( const char *  path,
char *  buff,
size_t  size 
)

Read the value of a symbolic link.

It tries to emulate readlink system call.

To get more information, execute in a terminal the command man 2 readlink

Parameters
pathpath to the symbolic link
buffpointer to the buffer where data to be read is to be stored
sizebuffer size in bytes
Returns
0 on success; -errno in case of error, being errno the system error that better represents the cause of failure