OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
fsw_core.h File Reference
#include "fsw_base.h"

Go to the source code of this file.

Data Structures

struct  fsw_string
 
struct  fsw_blockcache
 
struct  fsw_volume
 
struct  fsw_dnode
 
struct  fsw_extent
 
struct  fsw_shandle
 
struct  fsw_volume_stat
 
struct  fsw_dnode_stat
 
struct  fsw_host_table
 
struct  fsw_fstype_table
 

Macros

#define FSW_PATH_MAX   (4096)
 
#define FSW_CONCAT3(a, b, c)
 
#define FSW_FSTYPE_TABLE_NAME(t)
 
#define FSW_INVALID_BNO   (~0U)
 
Posix Mode Macros

These macros can be used globally to test fields and bits in Posix-style modes.

Taken from FreeBSD sys/stat.h.

#define S_ISUID   0004000 /* set user id on execution */
 
#define S_ISGID   0002000 /* set group id on execution */
 
#define S_ISTXT   0001000 /* sticky bit */
 
#define S_IRWXU   0000700 /* RWX mask for owner */
 
#define S_IRUSR   0000400 /* R for owner */
 
#define S_IWUSR   0000200 /* W for owner */
 
#define S_IXUSR   0000100 /* X for owner */
 
#define S_IRWXG   0000070 /* RWX mask for group */
 
#define S_IRGRP   0000040 /* R for group */
 
#define S_IWGRP   0000020 /* W for group */
 
#define S_IXGRP   0000010 /* X for group */
 
#define S_IRWXO   0000007 /* RWX mask for other */
 
#define S_IROTH   0000004 /* R for other */
 
#define S_IWOTH   0000002 /* W for other */
 
#define S_IXOTH   0000001 /* X for other */
 
#define S_IFMT   0170000 /* type of file mask */
 
#define S_IFIFO   0010000 /* named pipe (fifo) */
 
#define S_IFCHR   0020000 /* character special */
 
#define S_IFDIR   0040000 /* directory */
 
#define S_IFBLK   0060000 /* block special */
 
#define S_IFREG   0100000 /* regular */
 
#define S_IFLNK   0120000 /* symbolic link */
 
#define S_IFSOCK   0140000 /* socket */
 
#define S_ISVTX   0001000 /* save swapped text even after use */
 
#define S_IFWHT   0160000 /* whiteout */
 
#define S_ISDIR(m)
 
#define S_ISCHR(m)
 
#define S_ISBLK(m)
 
#define S_ISREG(m)
 
#define S_ISFIFO(m)
 
#define S_ISLNK(m)
 
#define S_ISSOCK(m)
 
#define S_ISWHT(m)
 
#define S_BLKSIZE   512 /* block size used in the stat struct */
 

Functions

Volume Functions
fsw_status_t fsw_mount (void *host_data, struct fsw_host_table *host_table, struct fsw_fstype_table *fstype_table, struct fsw_volume **vol_out)
 
void fsw_unmount (struct fsw_volume *vol)
 
fsw_status_t fsw_volume_stat (struct fsw_volume *vol, struct fsw_volume_stat *sb)
 
void fsw_set_blocksize (struct VOLSTRUCTNAME *vol, fsw_u32 phys_blocksize, fsw_u32 log_blocksize)
 
fsw_status_t fsw_block_get (struct VOLSTRUCTNAME *vol, fsw_u32 phys_bno, fsw_u32 cache_level, void **buffer_out)
 
void fsw_block_release (struct VOLSTRUCTNAME *vol, fsw_u32 phys_bno, void *buffer)
 
dnode Functions
fsw_status_t fsw_dnode_create_root (struct VOLSTRUCTNAME *vol, fsw_u32 dnode_id, struct DNODESTRUCTNAME **dno_out)
 
fsw_status_t fsw_dnode_create (struct VOLSTRUCTNAME *vol, struct DNODESTRUCTNAME *parent_dno, fsw_u32 dnode_id, int type, struct fsw_string *name, struct DNODESTRUCTNAME **dno_out)
 
void fsw_dnode_mkcomplete (struct DNODESTRUCTNAME *dno)
 
int fsw_dnode_is_root (struct fsw_dnode *dno)
 
void fsw_dnode_retain (struct fsw_dnode *dno)
 
void fsw_dnode_release (struct fsw_dnode *dno)
 
fsw_status_t fsw_dnode_fill (struct fsw_dnode *dno)
 
fsw_status_t fsw_dnode_stat (struct fsw_dnode *dno, struct fsw_dnode_stat *sb)
 
fsw_status_t fsw_dnode_lookup (struct fsw_dnode *dno, struct fsw_string *lookup_name, struct fsw_dnode **child_dno_out)
 
fsw_status_t fsw_dnode_lookup_path (struct fsw_dnode *dno, struct fsw_string *lookup_path, char separator, struct fsw_dnode **child_dno_out)
 
fsw_status_t fsw_dnode_dir_read (struct fsw_shandle *shand, struct fsw_dnode **child_dno_out)
 
fsw_status_t fsw_dnode_readlink (struct fsw_dnode *dno, struct fsw_string *link_target)
 
fsw_status_t fsw_dnode_readlink_data (struct DNODESTRUCTNAME *dno, struct fsw_string *link_target)
 
fsw_status_t fsw_dnode_resolve (struct fsw_dnode *dno, struct fsw_dnode **target_dno_out)
 
fsw_status_t fsw_dnode_get_path (struct VOLSTRUCTNAME *vol, struct DNODESTRUCTNAME *dno, struct fsw_string *out_path)
 
fsw_status_t fsw_get_bless_info (struct VOLSTRUCTNAME *vol, int type, struct fsw_string *out_path)
 
shandle Functions
fsw_status_t fsw_shandle_open (struct DNODESTRUCTNAME *dno, struct fsw_shandle *shand)
 
void fsw_shandle_close (struct fsw_shandle *shand)
 
fsw_status_t fsw_shandle_read (struct fsw_shandle *shand, fsw_u32 *buffer_size_inout, void *buffer)
 
Memory Functions
fsw_status_t fsw_alloc_zero (int len, void **ptr_out)
 
fsw_status_t fsw_memdup (void **dest_out, void *src, int len)
 
String Functions
int fsw_strlen (struct fsw_string *s)
 
int fsw_strsize (struct fsw_string *s)
 
void * fsw_strdata (struct fsw_string *s)
 
int fsw_streq (struct fsw_string *s1, struct fsw_string *s2)
 
int fsw_streq_cstr (struct fsw_string *s1, const char *s2)
 
fsw_status_t fsw_strdup_coerce (struct fsw_string *dest, int type, struct fsw_string *src)
 
void fsw_strsplit (struct fsw_string *lookup_name, struct fsw_string *buffer, char separator)
 
void fsw_strfree (struct fsw_string *s)
 

Byte Order Macros

Implements big endian vs. little endian awareness and conversion.

#define FSW_SWAPVALUE_U16(v)
 
#define FSW_SWAPVALUE_U32(v)
 
#define FSW_SWAPVALUE_U64(v)
 
#define VOLSTRUCTNAME   fsw_volume
 
#define DNODESTRUCTNAME   fsw_dnode
 
#define FSW_STRING_TYPE_UTF16_LE   FSW_STRING_TYPE_UTF16_SWAPPED
 
#define FSW_STRING_TYPE_UTF16_BE   FSW_STRING_TYPE_UTF16
 
#define FSW_STRING_INIT   { FSW_STRING_TYPE_EMPTY, 0, 0, NULL }
 
enum  {
  FSW_SUCCESS , FSW_OUT_OF_MEMORY , FSW_IO_ERROR , FSW_UNSUPPORTED ,
  FSW_NOT_FOUND , FSW_VOLUME_CORRUPTED , FSW_UNKNOWN_ERROR
}
 
enum  {
  FSW_STRING_TYPE_EMPTY , FSW_STRING_TYPE_ISO88591 , FSW_STRING_TYPE_UTF8 , FSW_STRING_TYPE_UTF16 ,
  FSW_STRING_TYPE_UTF16_SWAPPED
}
 
enum  {
  FSW_DNODE_TYPE_UNKNOWN , FSW_DNODE_TYPE_FILE , FSW_DNODE_TYPE_DIR , FSW_DNODE_TYPE_SYMLINK ,
  FSW_DNODE_TYPE_SPECIAL
}
 
enum  { BLESSED_TYPE_SYSTEM_FILE , BLESSED_TYPE_SYSTEM_FOLDER , BLESSED_TYPE_OSX_FOLDER }
 
enum  { FSW_EXTENT_TYPE_INVALID , FSW_EXTENT_TYPE_SPARSE , FSW_EXTENT_TYPE_PHYSBLOCK , FSW_EXTENT_TYPE_BUFFER }
 
enum  { FSW_DNODE_STAT_CTIME , FSW_DNODE_STAT_MTIME , FSW_DNODE_STAT_ATIME }
 
typedef fsw_u16 fsw_u16_le
 
typedef fsw_u16 fsw_u16_be
 
typedef fsw_u32 fsw_u32_le
 
typedef fsw_u32 fsw_u32_be
 
typedef fsw_u64 fsw_u64_le
 
typedef fsw_u64 fsw_u64_be
 
typedef int fsw_status_t
 

Detailed Description

Core file system wrapper abstraction layer header.

Definition in file fsw_core.h.

Macro Definition Documentation

◆ DNODESTRUCTNAME

#define DNODESTRUCTNAME   fsw_dnode

Definition at line 144 of file fsw_core.h.

◆ FSW_CONCAT3

#define FSW_CONCAT3 ( a,
b,
c )
Value:
a##b##c

Helper macro for token concatenation.

Definition at line 51 of file fsw_core.h.

◆ FSW_FSTYPE_TABLE_NAME

#define FSW_FSTYPE_TABLE_NAME ( t)
Value:
FSW_CONCAT3(fsw_,t,_table)
#define FSW_CONCAT3(a, b, c)
Definition fsw_core.h:51

Expands to the name of a fstype dispatch table (fsw_fstype_table) for a named file system type.

Definition at line 53 of file fsw_core.h.

◆ FSW_INVALID_BNO

#define FSW_INVALID_BNO   (~0U)

Indicates that the block cache entry is empty.

Definition at line 56 of file fsw_core.h.

◆ FSW_PATH_MAX

#define FSW_PATH_MAX   (4096)

Maximum size for a path, specifically symlink target paths.

Definition at line 48 of file fsw_core.h.

◆ FSW_STRING_INIT

#define FSW_STRING_INIT   { FSW_STRING_TYPE_EMPTY, 0, 0, NULL }

Static initializer for an empty string.

Definition at line 201 of file fsw_core.h.

◆ FSW_STRING_TYPE_UTF16_BE

#define FSW_STRING_TYPE_UTF16_BE   FSW_STRING_TYPE_UTF16

Definition at line 197 of file fsw_core.h.

◆ FSW_STRING_TYPE_UTF16_LE

#define FSW_STRING_TYPE_UTF16_LE   FSW_STRING_TYPE_UTF16_SWAPPED

Definition at line 196 of file fsw_core.h.

◆ FSW_SWAPVALUE_U16

#define FSW_SWAPVALUE_U16 ( v)
Value:
((((fsw_u16)(v) & 0xff00) >> 8) | \
(((fsw_u16)(v) & 0x00ff) << 8))
UINT16 fsw_u16

Definition at line 77 of file fsw_core.h.

◆ FSW_SWAPVALUE_U32

#define FSW_SWAPVALUE_U32 ( v)
Value:
((((fsw_u32)(v) & 0xff000000UL) >> 24) | \
(((fsw_u32)(v) & 0x00ff0000UL) >> 8) | \
(((fsw_u32)(v) & 0x0000ff00UL) << 8) | \
(((fsw_u32)(v) & 0x000000ffUL) << 24))
UINT32 fsw_u32

Definition at line 79 of file fsw_core.h.

◆ FSW_SWAPVALUE_U64

#define FSW_SWAPVALUE_U64 ( v)
Value:
((((fsw_u64)(v) & 0xff00000000000000ULL) >> 56) | \
(((fsw_u64)(v) & 0x00ff000000000000ULL) >> 40) | \
(((fsw_u64)(v) & 0x0000ff0000000000ULL) >> 24) | \
(((fsw_u64)(v) & 0x000000ff00000000ULL) >> 8) | \
(((fsw_u64)(v) & 0x00000000ff000000ULL) << 8) | \
(((fsw_u64)(v) & 0x0000000000ff0000ULL) << 24) | \
(((fsw_u64)(v) & 0x000000000000ff00ULL) << 40) | \
(((fsw_u64)(v) & 0x00000000000000ffULL) << 56))
UINT64 fsw_u64

Definition at line 83 of file fsw_core.h.

◆ S_BLKSIZE

#define S_BLKSIZE   512 /* block size used in the stat struct */

Definition at line 527 of file fsw_core.h.

◆ S_IFBLK

#define S_IFBLK   0060000 /* block special */

Definition at line 511 of file fsw_core.h.

◆ S_IFCHR

#define S_IFCHR   0020000 /* character special */

Definition at line 509 of file fsw_core.h.

◆ S_IFDIR

#define S_IFDIR   0040000 /* directory */

Definition at line 510 of file fsw_core.h.

◆ S_IFIFO

#define S_IFIFO   0010000 /* named pipe (fifo) */

Definition at line 508 of file fsw_core.h.

◆ S_IFLNK

#define S_IFLNK   0120000 /* symbolic link */

Definition at line 513 of file fsw_core.h.

◆ S_IFMT

#define S_IFMT   0170000 /* type of file mask */

Definition at line 507 of file fsw_core.h.

◆ S_IFREG

#define S_IFREG   0100000 /* regular */

Definition at line 512 of file fsw_core.h.

◆ S_IFSOCK

#define S_IFSOCK   0140000 /* socket */

Definition at line 514 of file fsw_core.h.

◆ S_IFWHT

#define S_IFWHT   0160000 /* whiteout */

Definition at line 516 of file fsw_core.h.

◆ S_IRGRP

#define S_IRGRP   0000040 /* R for group */

Definition at line 498 of file fsw_core.h.

◆ S_IROTH

#define S_IROTH   0000004 /* R for other */

Definition at line 503 of file fsw_core.h.

◆ S_IRUSR

#define S_IRUSR   0000400 /* R for owner */

Definition at line 493 of file fsw_core.h.

◆ S_IRWXG

#define S_IRWXG   0000070 /* RWX mask for group */

Definition at line 497 of file fsw_core.h.

◆ S_IRWXO

#define S_IRWXO   0000007 /* RWX mask for other */

Definition at line 502 of file fsw_core.h.

◆ S_IRWXU

#define S_IRWXU   0000700 /* RWX mask for owner */

Definition at line 492 of file fsw_core.h.

◆ S_ISBLK

#define S_ISBLK ( m)
Value:
(((m) & 0170000) == 0060000) /* block special */

Definition at line 520 of file fsw_core.h.

◆ S_ISCHR

#define S_ISCHR ( m)
Value:
(((m) & 0170000) == 0020000) /* char special */

Definition at line 519 of file fsw_core.h.

◆ S_ISDIR

#define S_ISDIR ( m)
Value:
(((m) & 0170000) == 0040000) /* directory */

Definition at line 518 of file fsw_core.h.

◆ S_ISFIFO

#define S_ISFIFO ( m)
Value:
(((m) & 0170000) == 0010000) /* fifo or socket */

Definition at line 522 of file fsw_core.h.

◆ S_ISGID

#define S_ISGID   0002000 /* set group id on execution */

Definition at line 489 of file fsw_core.h.

◆ S_ISLNK

#define S_ISLNK ( m)
Value:
(((m) & 0170000) == 0120000) /* symbolic link */

Definition at line 523 of file fsw_core.h.

◆ S_ISREG

#define S_ISREG ( m)
Value:
(((m) & 0170000) == 0100000) /* regular file */

Definition at line 521 of file fsw_core.h.

◆ S_ISSOCK

#define S_ISSOCK ( m)
Value:
(((m) & 0170000) == 0140000) /* socket */

Definition at line 524 of file fsw_core.h.

◆ S_ISTXT

#define S_ISTXT   0001000 /* sticky bit */

Definition at line 490 of file fsw_core.h.

◆ S_ISUID

#define S_ISUID   0004000 /* set user id on execution */

Definition at line 488 of file fsw_core.h.

◆ S_ISVTX

#define S_ISVTX   0001000 /* save swapped text even after use */

Definition at line 515 of file fsw_core.h.

◆ S_ISWHT

#define S_ISWHT ( m)
Value:
(((m) & 0170000) == 0160000) /* whiteout */

Definition at line 525 of file fsw_core.h.

◆ S_IWGRP

#define S_IWGRP   0000020 /* W for group */

Definition at line 499 of file fsw_core.h.

◆ S_IWOTH

#define S_IWOTH   0000002 /* W for other */

Definition at line 504 of file fsw_core.h.

◆ S_IWUSR

#define S_IWUSR   0000200 /* W for owner */

Definition at line 494 of file fsw_core.h.

◆ S_IXGRP

#define S_IXGRP   0000010 /* X for group */

Definition at line 500 of file fsw_core.h.

◆ S_IXOTH

#define S_IXOTH   0000001 /* X for other */

Definition at line 505 of file fsw_core.h.

◆ S_IXUSR

#define S_IXUSR   0000100 /* X for owner */

Definition at line 495 of file fsw_core.h.

◆ VOLSTRUCTNAME

#define VOLSTRUCTNAME   fsw_volume

Definition at line 139 of file fsw_core.h.

Typedef Documentation

◆ fsw_status_t

typedef int fsw_status_t

Status code type, returned from all functions that can fail.

Definition at line 153 of file fsw_core.h.

◆ fsw_u16_be

Definition at line 71 of file fsw_core.h.

◆ fsw_u16_le

Definition at line 70 of file fsw_core.h.

◆ fsw_u32_be

Definition at line 73 of file fsw_core.h.

◆ fsw_u32_le

Definition at line 72 of file fsw_core.h.

◆ fsw_u64_be

Definition at line 75 of file fsw_core.h.

◆ fsw_u64_le

Definition at line 74 of file fsw_core.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Possible status codes.

Enumerator
FSW_SUCCESS 
FSW_OUT_OF_MEMORY 
FSW_IO_ERROR 
FSW_UNSUPPORTED 
FSW_NOT_FOUND 
FSW_VOLUME_CORRUPTED 
FSW_UNKNOWN_ERROR 

Definition at line 158 of file fsw_core.h.

◆ anonymous enum

anonymous enum

Possible string types / encodings. In the case of FSW_STRING_TYPE_EMPTY, all other members of the fsw_string structure may be invalid.

Enumerator
FSW_STRING_TYPE_EMPTY 
FSW_STRING_TYPE_ISO88591 
FSW_STRING_TYPE_UTF8 
FSW_STRING_TYPE_UTF16 
FSW_STRING_TYPE_UTF16_SWAPPED 

Definition at line 184 of file fsw_core.h.

◆ anonymous enum

anonymous enum

Possible dnode types. FSW_DNODE_TYPE_UNKNOWN may only be used before fsw_dnode_fill has been called on the dnode.

Enumerator
FSW_DNODE_TYPE_UNKNOWN 
FSW_DNODE_TYPE_FILE 
FSW_DNODE_TYPE_DIR 
FSW_DNODE_TYPE_SYMLINK 
FSW_DNODE_TYPE_SPECIAL 

Definition at line 263 of file fsw_core.h.

◆ anonymous enum

anonymous enum
Enumerator
BLESSED_TYPE_SYSTEM_FILE 
BLESSED_TYPE_SYSTEM_FOLDER 
BLESSED_TYPE_OSX_FOLDER 

Definition at line 271 of file fsw_core.h.

◆ anonymous enum

anonymous enum

Possible extent representation types. FSW_EXTENT_TYPE_INVALID is for shandle's internal use only, it must not be returned from a get_extent function.

Enumerator
FSW_EXTENT_TYPE_INVALID 
FSW_EXTENT_TYPE_SPARSE 
FSW_EXTENT_TYPE_PHYSBLOCK 
FSW_EXTENT_TYPE_BUFFER 

Definition at line 293 of file fsw_core.h.

◆ anonymous enum

anonymous enum

Type of the timestamp passed into store_time_posix.

Enumerator
FSW_DNODE_STAT_CTIME 
FSW_DNODE_STAT_MTIME 
FSW_DNODE_STAT_ATIME 

Definition at line 335 of file fsw_core.h.

Function Documentation

◆ fsw_alloc_zero()

fsw_status_t fsw_alloc_zero ( int len,
void ** ptr_out )

Allocate memory and clear it.

Definition at line 49 of file fsw_lib.c.

◆ fsw_block_get()

fsw_status_t fsw_block_get ( struct VOLSTRUCTNAME * vol,
fsw_u32 phys_bno,
fsw_u32 cache_level,
void ** buffer_out )

Get a block of data from the disk. This function is called by the file system driver or by core functions. It calls through to the host driver's device access routine. Given a physical block number, it reads the block into memory (or fetches it from the block cache) and returns the address of the memory buffer. The caller should provide an indication of how important the block is in the cache_level parameter. Blocks with a low level are purged first. Some suggestions for cache levels:

  • 0: File data
  • 1: Directory data, symlink data
  • 2: File system metadata
  • 3..5: File system metadata with a high rate of access

If this function returns successfully, the returned data pointer is valid until the caller calls fsw_block_release.

Definition at line 179 of file fsw_core.c.

◆ fsw_block_release()

void fsw_block_release ( struct VOLSTRUCTNAME * vol,
fsw_u32 phys_bno,
void * buffer )

Releases a disk block. This function must be called to release disk blocks returned from fsw_block_get.

Definition at line 267 of file fsw_core.c.

◆ fsw_dnode_create()

fsw_status_t fsw_dnode_create ( struct VOLSTRUCTNAME * vol,
struct DNODESTRUCTNAME * parent_dno,
fsw_u32 dnode_id,
int type,
struct fsw_string * name,
struct DNODESTRUCTNAME ** dno_out )

◆ fsw_dnode_create_root()

fsw_status_t fsw_dnode_create_root ( struct VOLSTRUCTNAME * vol,
fsw_u32 dnode_id,
struct DNODESTRUCTNAME ** dno_out )

◆ fsw_dnode_dir_read()

fsw_status_t fsw_dnode_dir_read ( struct fsw_shandle * shand,
struct fsw_dnode ** child_dno_out )

Get the next directory item in sequential order. This function is called by the host driver to read the complete contents of a directory in sequential (file system defined) order. Calling this function returns the next entry. Iteration state is kept by a shandle on the directory's dnode. The caller must set up the shandle when starting the iteration.

When the end of the directory is reached, this function returns FSW_NOT_FOUND. If the function returns FSW_SUCCESS, *child_dno_out points to the next directory entry. The caller must call fsw_dnode_release on it.

Definition at line 669 of file fsw_core.c.

◆ fsw_dnode_fill()

fsw_status_t fsw_dnode_fill ( struct fsw_dnode * dno)

Get full information about a dnode from disk. This function is called by the host driver as well as by the core functions. Some file systems defer reading full information on a dnode until it is actually needed (i.e. separation between directory and inode information). This function makes sure that all information is available in the dnode structure. The following fields may not have a correct value until fsw_dnode_fill has been called:

type, size

Definition at line 483 of file fsw_core.c.

◆ fsw_dnode_get_path()

fsw_status_t fsw_dnode_get_path ( struct VOLSTRUCTNAME * vol,
struct DNODESTRUCTNAME * dno,
struct fsw_string * out_path )

◆ fsw_dnode_is_root()

int fsw_dnode_is_root ( struct fsw_dnode * dno)

Definition at line 350 of file fsw_core.c.

◆ fsw_dnode_lookup()

fsw_status_t fsw_dnode_lookup ( struct fsw_dnode * dno,
struct fsw_string * lookup_name,
struct fsw_dnode ** child_dno_out )

Lookup a directory entry by name. This function is called by the host driver. Given a directory dnode and a file name, it looks up the named entry in the directory.

If the dnode is not a directory, the call will fail. The caller is responsible for resolving symbolic links before calling this function.

If the function returns FSW_SUCCESS, *child_dno_out points to the requested directory entry. The caller must call fsw_dnode_release on it.

Definition at line 529 of file fsw_core.c.

◆ fsw_dnode_lookup_path()

fsw_status_t fsw_dnode_lookup_path ( struct fsw_dnode * dno,
struct fsw_string * lookup_path,
char separator,
struct fsw_dnode ** child_dno_out )

Find a file system object by path. This function is called by the host driver. Given a directory dnode and a relative or absolute path, it walks the directory tree until it finds the target dnode. If an intermediate node turns out to be a symlink, it is resolved automatically. If the target node is a symlink, it is not resolved.

If the function returns FSW_SUCCESS, *child_dno_out points to the requested directory entry. The caller must call fsw_dnode_release on it.

Definition at line 554 of file fsw_core.c.

◆ fsw_dnode_mkcomplete()

void fsw_dnode_mkcomplete ( struct DNODESTRUCTNAME * dno)

◆ fsw_dnode_readlink()

fsw_status_t fsw_dnode_readlink ( struct fsw_dnode * dno,
struct fsw_string * target_name )

Read the target path of a symbolic link. This function is called by the host driver to read the "content" of a symbolic link, that is the relative or absolute path it points to.

If the function returns FSW_SUCCESS, the string handle provided by the caller is filled with a string in the host's preferred encoding. The caller is responsible for calling fsw_strfree on the string.

Definition at line 695 of file fsw_core.c.

◆ fsw_dnode_readlink_data()

fsw_status_t fsw_dnode_readlink_data ( struct DNODESTRUCTNAME * dno,
struct fsw_string * link_target )

◆ fsw_dnode_release()

void fsw_dnode_release ( struct fsw_dnode * dno)

Release a dnode pointer, deallocating it if this was the last reference. This function decrements the reference counter of the dnode. If the counter reaches zero, the dnode is freed. Since the parent dnode is released during that process, this function may cause it to be freed, too.

Definition at line 442 of file fsw_core.c.

◆ fsw_dnode_resolve()

fsw_status_t fsw_dnode_resolve ( struct fsw_dnode * dno,
struct fsw_dnode ** target_dno_out )

Resolve a symbolic link. This function can be called by the host driver to make sure the a dnode is fully resolved instead of pointing at a symlink. If the dnode passed in is not a symlink, it is returned unmodified.

Note that absolute paths will be resolved relative to the root directory of the volume. If the host is an operating system with its own VFS layer, it should resolve symlinks on its own.

If the function returns FSW_SUCCESS, *target_dno_out points at a dnode that is not a symlink. The caller is responsible for calling fsw_dnode_release on it.

Definition at line 764 of file fsw_core.c.

◆ fsw_dnode_retain()

void fsw_dnode_retain ( struct fsw_dnode * dno)

Increases the reference count of a dnode. This must be balanced with fsw_dnode_release calls. Note that some dnode functions return a retained dnode pointer to their caller.

Definition at line 430 of file fsw_core.c.

◆ fsw_dnode_stat()

fsw_status_t fsw_dnode_stat ( struct fsw_dnode * dno,
struct fsw_dnode_stat * sb )

Get extended information about a dnode. This function can be called by the host driver to get a full compliment of information about a dnode in addition to the fields of the fsw_dnode structure itself.

Some data requires host-specific conversion to be useful (i.e. timestamps) and will be passed to callback functions instead of being written into the structure. These callbacks must be filled in by the caller.

Definition at line 502 of file fsw_core.c.

◆ fsw_get_bless_info()

fsw_status_t fsw_get_bless_info ( struct VOLSTRUCTNAME * vol,
int type,
struct fsw_string * out_path )

◆ fsw_memdup()

fsw_status_t fsw_memdup ( void ** dest_out,
void * src,
int len )

Duplicate a piece of data.

Definition at line 64 of file fsw_lib.c.

◆ fsw_mount()

fsw_status_t fsw_mount ( void * host_data,
struct fsw_host_table * host_table,
struct fsw_fstype_table * fstype_table,
struct fsw_volume ** vol_out )

Mount a volume with a given file system driver. This function is called by the host driver to make a volume accessible. The file system driver to use is specified by a pointer to its dispatch table. The file system driver will look at the data on the volume to determine if it can read the format. If the volume is found unsuitable, FSW_UNSUPPORTED is returned.

If this function returns FSW_SUCCESS, *vol_out points at a valid volume data structure. The caller must release it later by calling fsw_unmount.

If this function returns an error status, the caller only needs to clean up its own buffers that may have been allocated through the read_block interface.

Definition at line 62 of file fsw_core.c.

◆ fsw_set_blocksize()

void fsw_set_blocksize ( struct VOLSTRUCTNAME * vol,
fsw_u32 phys_blocksize,
fsw_u32 log_blocksize )

◆ fsw_shandle_close()

void fsw_shandle_close ( struct fsw_shandle * shand)

Close a shandle after accessing the dnode's data. This function is called by the host driver or core functions when they are finished with accessing a file's data. It releases the dnode reference and frees any buffers associated with the shandle itself. The dnode is only released if this was the last reference using it.

Definition at line 848 of file fsw_core.c.

◆ fsw_shandle_open()

fsw_status_t fsw_shandle_open ( struct DNODESTRUCTNAME * dno,
struct fsw_shandle * shand )

◆ fsw_shandle_read()

fsw_status_t fsw_shandle_read ( struct fsw_shandle * shand,
fsw_u32 * buffer_size_inout,
void * buffer_in )

Read data from a shandle (storage handle for a dnode). This function is called by the host driver or internally when data is read from a file. TODO: more

Definition at line 860 of file fsw_core.c.

◆ fsw_strdata()

void * fsw_strdata ( struct fsw_string * s)

Get the data of a string.

Definition at line 100 of file fsw_lib.c.

◆ fsw_strdup_coerce()

fsw_status_t fsw_strdup_coerce ( struct fsw_string * dest,
int type,
struct fsw_string * src )

Creates a duplicate of a string, converting it to the given encoding during the copy. If the function returns FSW_SUCCESS, the caller must free the string later with fsw_strfree.

Definition at line 190 of file fsw_lib.c.

◆ fsw_streq()

int fsw_streq ( struct fsw_string * s1,
struct fsw_string * s2 )

Compare two strings for equality. The two strings are compared, taking their encoding into account. If they are considered equal, boolean true is returned. Otherwise, boolean false is returned.

Definition at line 114 of file fsw_lib.c.

◆ fsw_streq_cstr()

int fsw_streq_cstr ( struct fsw_string * s1,
const char * s2 )

Compare a string with a C string constant. This sets up a string descriptor for the string constant (second argument) and runs fsw_streq on the two strings. Currently the C string is interpreted as ISO 8859-1. Returns boolean true if the strings are considered equal, boolean false otherwise.

Definition at line 169 of file fsw_lib.c.

◆ fsw_strfree()

void fsw_strfree ( struct fsw_string * s)

Frees the memory used by a string returned from fsw_strdup_coerce.

Definition at line 310 of file fsw_lib.c.

◆ fsw_strlen()

int fsw_strlen ( struct fsw_string * s)

Get the length of a string. Returns the number of characters in the string.

Definition at line 79 of file fsw_lib.c.

◆ fsw_strsize()

int fsw_strsize ( struct fsw_string * s)

Get the size of a string in bytes.

Definition at line 89 of file fsw_lib.c.

◆ fsw_strsplit()

void fsw_strsplit ( struct fsw_string * element,
struct fsw_string * buffer,
char separator )

Splits a string at the first occurence of the separator character. The buffer string is searched for the separator character. If it is found, the element string descriptor is filled to point at the part of the buffer string before the separator. The buffer string itself is adjusted to point at the remaining part of the string (without the separator).

If the separator is not found in the buffer string, then element is changed to point at the whole buffer string, and the buffer string itself is changed into an empty string.

This function only manipulates the pointers and lengths in the two string descriptors, it does not change the actual string. If the buffer string is dynamically allocated, you must make a copy of it so that you can release it later.

Definition at line 246 of file fsw_lib.c.

◆ fsw_unmount()

void fsw_unmount ( struct fsw_volume * vol)

Unmount a volume by releasing all memory associated with it. This function is called by the host driver when a volume is no longer needed. It is also called by the core after a failed mount to clean up any allocated memory.

Note that all dnodes must have been released before calling this function.

Definition at line 107 of file fsw_core.c.

◆ fsw_volume_stat()

fsw_status_t fsw_volume_stat ( struct fsw_volume * vol,
struct fsw_volume_stat * sb )

Get in-depth information on the volume. This function can be called by the host driver to get additional information on the volume.

Definition at line 125 of file fsw_core.c.