The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
ext2_link.c File Reference

hard links, symbolic links, and the inodes with no data: named pipes and device nodes. More...

#include "ext2_internal.h"
#include "common/memory.h"
#include "common/string.h"

Macros

#define FAST_LINK_MAX   ((uint32_t)sizeof(((ext2_inode_t *)0)->i_block))

Functions

bool inode_is_symlink (const ext2_inode_t *inode)
bool inode_is_fast_symlink (const ext2_inode_t *inode)
kerr_t ext2_find_link (ext2_volume_t *volume, const char *path, bool follow_last, char *target, uint32_t size, uint32_t *end_out)
 find the first symbolic link along a path.
kerr_t ext2_readlink (ext2_volume_t *volume, const char *path, char *target, uint32_t size)
 read a symbolic link's target, with a NUL.
kerr_t ext2_symlink (ext2_volume_t *volume, const char *path, const char *target)
 make a symbolic link at path that points at target.
kerr_t ext2_link (ext2_volume_t *volume, const char *old_path, const char *new_path)
 give the file at old_path one more name, new_path.
kerr_t ext2_mknod (ext2_volume_t *volume, const char *path, uint32_t mode, uint32_t major, uint32_t minor)
 make a named pipe or a device node.
void ext2_device_numbers (const ext2_inode_t *inode, uint32_t *major, uint32_t *minor)
 the numbers of a device node, as ext2_mknod stored them.
bool inode_has_no_blocks (const ext2_inode_t *inode)

Detailed Description

hard links, symbolic links, and the inodes with no data: named pipes and device nodes.

a hard link is one more directory entry for an inode: the inode counts its names in i_links_count, and its data stays until the last name goes.

a symbolic link is an inode of type S_IFLNK whose data is the path it points at. a short path (shorter than the 60 bytes of i_block) is kept in i_block itself, with no data block (a "fast" link, i_blocks 0). a longer path is in one data block, so a target is shorter than a block.

Macro Definition Documentation

◆ FAST_LINK_MAX

#define FAST_LINK_MAX   ((uint32_t)sizeof(((ext2_inode_t *)0)->i_block))

Function Documentation

◆ inode_is_symlink()

bool inode_is_symlink ( const ext2_inode_t * inode)

◆ inode_is_fast_symlink()

bool inode_is_fast_symlink ( const ext2_inode_t * inode)

◆ ext2_find_link()

kerr_t ext2_find_link ( ext2_volume_t * volume,
const char * path,
bool follow_last,
char * target,
uint32_t size,
uint32_t * end_out )

find the first symbolic link along a path.

Parameters
follow_lastalso the last name of the path, when it is a link.
targetgets the link's target, with a NUL.
end_outgets the length of the path up to and with the link's name, or 0 when there is no link (or a name is missing).
Returns
KERR_OK, KERR_RANGE (the target is longer than size), KERR_IO.

◆ ext2_readlink()

kerr_t ext2_readlink ( ext2_volume_t * volume,
const char * path,
char * target,
uint32_t size )

read a symbolic link's target, with a NUL.

Returns
KERR_OK, KERR_INVAL (not a link), KERR_RANGE (too long for size), KERR_NOTFOUND.

◆ ext2_symlink()

kerr_t ext2_symlink ( ext2_volume_t * volume,
const char * path,
const char * target )

make a symbolic link at path that points at target.

Returns
KERR_OK, KERR_EXIST, KERR_RANGE (the target is not shorter than a block), KERR_NOTFOUND (no parent), KERR_NOSPC.

◆ ext2_link()

kerr_t ext2_link ( ext2_volume_t * volume,
const char * old_path,
const char * new_path )

give the file at old_path one more name, new_path.

Returns
KERR_OK, KERR_ISDIR (a directory), KERR_EXIST, KERR_RANGE (too many links), KERR_NOTFOUND, KERR_NOSPC.

◆ ext2_mknod()

kerr_t ext2_mknod ( ext2_volume_t * volume,
const char * path,
uint32_t mode,
uint32_t major,
uint32_t minor )

make a named pipe or a device node.

Parameters
modethe type (EXT2_S_IFIFO, EXT2_S_IFCHR, EXT2_S_IFBLK) and the permission bits.
majorthe device's numbers (a device node only).
Returns
KERR_OK, KERR_EXIST, KERR_NOTFOUND (no parent), KERR_NOSPC, KERR_INVAL (another type).

◆ ext2_device_numbers()

void ext2_device_numbers ( const ext2_inode_t * inode,
uint32_t * major,
uint32_t * minor )

the numbers of a device node, as ext2_mknod stored them.

◆ inode_has_no_blocks()

bool inode_has_no_blocks ( const ext2_inode_t * inode)