RTEMS  5.1
Macros | Functions

RTEMS File Systems Directory Routines. More...

#include <inttypes.h>
#include <string.h>
#include <rtems/rfs/rtems-rfs-block.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
#include <rtems/rfs/rtems-rfs-trace.h>
#include <rtems/rfs/rtems-rfs-dir.h>
#include <rtems/rfs/rtems-rfs-dir-hash.h>

Macros

#define rtems_rfs_dir_entry_valid(_f, _l, _i)
 

Functions

int rtems_rfs_dir_lookup_ino (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *inode, const char *name, int length, rtems_rfs_ino *ino, uint32_t *offset)
 
int rtems_rfs_dir_add_entry (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *dir, const char *name, size_t length, rtems_rfs_ino ino)
 
int rtems_rfs_dir_del_entry (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *dir, rtems_rfs_ino ino, uint32_t offset)
 
int rtems_rfs_dir_read (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *dir, rtems_rfs_pos_rel offset, struct dirent *dirent, size_t *length)
 
int rtems_rfs_dir_empty (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *dir)
 

Detailed Description

RTEMS File Systems Directory Routines.

These functions manage blocks in the directory format. A directory entry is a variable length record in the block. The entry consists of a length, hash and the string. The length allows the next entry to be located and the hash allows a simple check to be performed without a string compare. Directory entries do not span a block and removal of an entry results in the space in the block being compacted and the spare area being initialised to ones.

The maximum length can be 1 or 2 bytes depending on the value in the superblock.

Macro Definition Documentation

◆ rtems_rfs_dir_entry_valid

#define rtems_rfs_dir_entry_valid (   _f,
  _l,
  _i 
)
Value:
(((_l) <= RTEMS_RFS_DIR_ENTRY_SIZE) || ((_l) >= rtems_rfs_fs_max_name (_f)) \
|| (_i < RTEMS_RFS_ROOT_INO) || (_i > rtems_rfs_fs_inodes (_f)))
#define rtems_rfs_fs_inodes(_fs)
Definition: rtems-rfs-file-system.h:320
#define RTEMS_RFS_ROOT_INO
Definition: rtems-rfs-file-system.h:56
#define rtems_rfs_fs_max_name(_fs)
Definition: rtems-rfs-file-system.h:360
#define RTEMS_RFS_DIR_ENTRY_SIZE
Definition: rtems-rfs-dir.h:54

Validate the directory entry data.

Function Documentation

◆ rtems_rfs_dir_add_entry()

int rtems_rfs_dir_add_entry ( rtems_rfs_file_system fs,
rtems_rfs_inode_handle dir,
const char *  name,
size_t  length,
rtems_rfs_ino  ino 
)

Add an entry to the directory returing the inode number allocated to the entry.

Parameters
[in]fsis the file system data.
[in]diris a pointer to the directory inode the entry is to be added too.
[in]nameis a pointer to the name of the entry to be added.
[in]lengthis the length of the name excluding a terminating 0.
[in]inois the ino of the entry.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_dir_del_entry()

int rtems_rfs_dir_del_entry ( rtems_rfs_file_system fs,
rtems_rfs_inode_handle dir,
rtems_rfs_ino  ino,
uint32_t  offset 
)

Del an entry from the directory using an inode number as a key.

Parameters
[in]fsis the file system data.
[in]diris a pointer to the directory inode the entry is to be deleted from.
[in]inois the ino of the entry.
[in]offsetis the offset in the directory of the entry to delete. If 0 search from the start for the ino.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_dir_empty()

int rtems_rfs_dir_empty ( rtems_rfs_file_system fs,
rtems_rfs_inode_handle dir 
)

Check if the directory is empty. The current and parent directory entries are ignored.

Parameters
[in]fsis the file system data
[in]diris a pointer to the directory inode to check.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_dir_lookup_ino()

int rtems_rfs_dir_lookup_ino ( rtems_rfs_file_system fs,
rtems_rfs_inode_handle inode,
const char *  name,
int  length,
rtems_rfs_ino ino,
uint32_t *  offset 
)

Look up a directory entry in the directory pointed to by the inode. The look up is local to this directory. No need to decend.

Parameters
[in]fsis the file system.
[in]inodeis a pointer to the inode of the directory to search.
[in]nameis a pointer to the name to look up. The name may not be nul terminated.
[in]lengthis the length of the name.
[out]inowill be filled in with the inode number if there is no error.
[in]offsetis the offset in the directory for the entry.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_dir_read()

int rtems_rfs_dir_read ( rtems_rfs_file_system fs,
rtems_rfs_inode_handle dir,
rtems_rfs_pos_rel  offset,
struct dirent *  dirent,
size_t *  length 
)

Read the directory entry from offset into the directory entry buffer and return the length of space this entry uses in the directory table.

Parameters
[in]fsis the file system data.
[in]diris a pointer to the direct inode handler.
[in]offsetis the offset in the directory to read from.
[in]direntis a ointer to the dirent structure the entry is written into.
[out]lengthwill contain the length this entry takes in the directory.
Return values
0Successful operation.
error_codeAn error occurred.