RTEMS: cpukit/include/rtems/rfs/rtems-rfs-dir.h File Reference

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Macros | Functions
rtems-rfs-dir.h File Reference
IO Library » File System Types and Mount » RTEMS File System Group Management

RTEMS File System Directory Support. More...

`#include <dirent.h>`
`#include <rtems/libio_.h>`
`#include <rtems/rfs/rtems-rfs-data.h>`
`#include <rtems/rfs/rtems-rfs-file-system.h>`
`#include <rtems/rfs/rtems-rfs-inode.h>`

Go to the source code of this file.

## Macros
#define | RTEMS_RFS_DIR_ENTRY_INO (0)
#define | RTEMS_RFS_DIR_ENTRY_HASH (4)
#define | RTEMS_RFS_DIR_ENTRY_LEN (8)
#define | RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2)
#define | RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff)
#define | rtems_rfs_dir_entry_hash(_e) rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH)
#define | rtems_rfs_dir_set_entry_hash(_e, _h) rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h)
#define | rtems_rfs_dir_entry_ino(_e) rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO)
#define | rtems_rfs_dir_set_entry_ino(_e, _i) rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i)
#define | rtems_rfs_dir_entry_length(_e) rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN)
#define | rtems_rfs_dir_set_entry_length(_e, _l) rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l)

## 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 System Directory Support.

RTEMS File System Directory Support

This file provides the directory support functions.

## Macro Definition Documentation

## ◆ RTEMS_RFS_DIR_ENTRY_EMPTY

#define RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff)

The length when the remainder of the directory block is empty.

## ◆ RTEMS_RFS_DIR_ENTRY_HASH

#define RTEMS_RFS_DIR_ENTRY_HASH (4)

The hash offset in a directory entry. The hash is 32bits. We need at least 16bits and given the length and ino field are 4 the extra 2 bytes is not a big overhead.

## ◆ rtems_rfs_dir_entry_hash

#define rtems_rfs_dir_entry_hash | ( |  | _e | ) | rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH)

Return the hash of the entry.

Parameters

  [in] | _e | is a pointer to the directory entry.

Return values

  hash | The uint32_t hash of the entry.

## ◆ RTEMS_RFS_DIR_ENTRY_INO

#define RTEMS_RFS_DIR_ENTRY_INO (0)

Define the offsets of the fields of a directory entry. The ino offset in a directory entry.

## ◆ rtems_rfs_dir_entry_ino

#define rtems_rfs_dir_entry_ino | ( |  | _e | ) | rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO)

Return the ino of the entry.

Parameters

  [in] | _e | is a pointer to the directory entry.

Return values

  ino | The ino of the entry.

## ◆ RTEMS_RFS_DIR_ENTRY_LEN

#define RTEMS_RFS_DIR_ENTRY_LEN (8)

The length offset in a directory entry.

## ◆ rtems_rfs_dir_entry_length

#define rtems_rfs_dir_entry_length | ( |  | _e | ) | rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN)

Return the length of the entry.

Parameters

  [in] | _e | Pointer to the directory entry.

Return values

  length | The length of the entry.

## ◆ RTEMS_RFS_DIR_ENTRY_SIZE

#define RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2)

The length of the directory entry header.

## ◆ rtems_rfs_dir_set_entry_hash

#define rtems_rfs_dir_set_entry_hash | ( |  | _e,
|  |  | _h
| ) |  | rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h)

Set the hash of the entry.

Parameters

  [in] | _e | is a pointer to the directory entry.
  [in] | _h | is the hash of the entry.

## ◆ rtems_rfs_dir_set_entry_ino

#define rtems_rfs_dir_set_entry_ino | ( |  | _e,
|  |  | _i
| ) |  | rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i)

Set the ino of the entry.

Parameters

  [in] | _e | is a pointer to the directory entry.
  [in] | _i | is the ino of the entry.

## ◆ rtems_rfs_dir_set_entry_length

#define rtems_rfs_dir_set_entry_length | ( |  | _e,
|  |  | _l
| ) |  | rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l)

Set the length of the entry.

Parameters

  [in] | _e | is a pointer to the directory entry.
  [in] | _l | is the length.

## 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] | fs | is the file system data.
  [in] | dir | is a pointer to the directory inode the entry is to be added too.
  [in] | name | is a pointer to the name of the entry to be added.
  [in] | length | is the length of the name excluding a terminating 0.
  [in] | ino | is the ino of the entry.

Return values

  0 | Successful operation.
  error_code | An 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] | fs | is the file system data.
  [in] | dir | is a pointer to the directory inode the entry is to be deleted from.
  [in] | ino | is the ino of the entry.
  [in] | offset | is the offset in the directory of the entry to delete. If 0 search from the start for the ino.

Return values

  0 | Successful operation.
  error_code | An 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] | fs | is the file system data
  [in] | dir | is a pointer to the directory inode to check.

Return values

  0 | Successful operation.
  error_code | An 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] | fs | is the file system.
  [in] | inode | is a pointer to the inode of the directory to search.
  [in] | name | is a pointer to the name to look up. The name may not be nul terminated.
  [in] | length | is the length of the name.
  [out] | ino | will be filled in with the inode number if there is no error.
  [in] | offset | is the offset in the directory for the entry.

Return values

  0 | Successful operation.
  error_code | An 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] | fs | is the file system data.
  [in] | dir | is a pointer to the direct inode handler.
  [in] | offset | is the offset in the directory to read from.
  [in] | dirent | is a ointer to the dirent structure the entry is written into.
  [out] | length | will contain the length this entry takes in the directory.

Return values

  0 | Successful operation.
  error_code | An error occurred.