File system API
-
struct fs_plat
Filesystem information
Definition
struct fs_plat {
char name[FS_MAX_NAME_LEN];
struct blk_desc *desc;
int part_num;
struct disk_partition part;
};
Members
nameName of the filesystem, or empty if not available
descBlock device descriptor, or NULL if not block-backed
part_numPartition number (valid only when desc is non-NULL)
partPartition information (valid only when desc is non-NULL)
Description
For block-device-backed filesystems, desc and part identify the underlying storage. Non-block filesystems (hostfs, rootfs) leave desc as NULL.
-
struct fs_priv
Private information for the FS devices
Definition
struct fs_priv {
bool mounted;
};
Members
mountedtrue if mounted
Parameters
struct udevice *devFilesystem device Return 0 if OK, -EISCONN if already mounted, other -ve on error
Parameters
struct udevice *devFilesystem device Return 0 if OK, -ENOTCONN if not mounted, other -ve on error
-
int fs_lookup_dir(struct udevice *dev, const char *path, struct udevice **dirp)
Look up a directory on a filesystem
Parameters
struct udevice *devFilesystem device
const char *pathPath to look up, “” or “/” for the root
struct udevice **dirpReturns associated directory device, creating if necessary Return 0 if OK, -ENOENT, other -ve on error
Description
If a new directory-device is created, its uclass data is set up also
-
int fs_do_ln(struct udevice *dev, const char *path, const char *target)
Create a symbolic link on a filesystem
Parameters
struct udevice *devFilesystem device
const char *pathPath of symlink to create (within the filesystem)
const char *targetTarget the symlink points to
Return
0 if OK, -ENOSYS if not supported, other -ve on error
-
int fs_do_rename(struct udevice *dev, const char *old_path, const char *new_path)
Rename or move a file on a filesystem
Parameters
struct udevice *devFilesystem device
const char *old_pathCurrent path (within the filesystem)
const char *new_pathNew path (within the filesystem)
Description
Both paths must be within the same filesystem.
Return
0 if OK, -ENOSYS if not supported, other -ve on error
-
int fs_readlink(struct udevice *dev, const char *path, char *buf, int size)
Read a symbolic link target on a filesystem
Parameters
struct udevice *devFilesystem device
const char *pathPath to the symbolic link (within the filesystem)
char *bufBuffer to receive the target path
int sizeSize of buffer
Return
length of target, -ENOSYS if not supported, other -ve on error
Parameters
struct udevice *devFilesystem device
struct fs_statfs *statsReturns filesystem statistics
Return
0 if OK, -ENOSYS if not supported, other -ve on error
Parameters
struct udevice *devFilesystem device
const char *pathPath of the file to delete (within the filesystem)
Return
0 if OK, -ENOSYS if not supported, other -ve on error
Parameters
struct udevice *devFilesystem device
const char *pathPath of the directory to create (within the filesystem)
Return
0 if OK, -ENOSYS if not supported, other -ve on error
-
int fs_split_path(const char *fname, char **subdirp, const char **leafp)
Get a list of subdirs in a filename
Parameters
const char *fnameFilename to parse
char **subdirpReturns an allocating string containing the subdirs, or “/” if none
const char **leafpReturns a pointer to the leaf filename, within fname
Description
For example, ‘/path/to/fred’ returns an alist containing allocated strings ‘path’ and ‘to’, with *leafp pointing to the ‘f’
-
void fs_split_path_inplace(char *fname, const char **dirp, const char **leafp)
Split a path into directory and leaf in place
Parameters
char *fnamePath to split (modified in place when it contains ‘/’)
const char **dirpReturns pointer to the directory part
const char **leafpReturns pointer to the leaf filename
Description
Modifies fname by null-terminating at the last ‘/’. Sets dirp to point to the directory part and leafp to the leaf. If there is no ‘/’, dirp is set to “” and leafp points to fname unchanged.