@@ -33,15 +33,31 @@ struct ext4l_fs_priv {
/**
* struct ext4l_dir_priv - Private info for ext4l directory devices
*
- * @strm: Directory stream from ext4l_opendir(), or NULL. Only one listing
- * at a time is supported per directory device
+ * @strm: Directory stream from ext4l_opendir_legacy(), or NULL. Only one
+ * listing at a time is supported per directory device
*/
struct ext4l_dir_priv {
struct fs_dir_stream *strm;
};
+/**
+ * ext4l_get_fs_dev() - Get the UCLASS_FS device from a child
+ *
+ * Walks up from a DIR or FILE device to find its UCLASS_FS parent.
+ *
+ * Return: UCLASS_FS device (always valid for properly constructed trees)
+ */
+static struct udevice *ext4l_get_fs_dev(struct udevice *dev)
+{
+ while (device_get_uclass_id(dev) != UCLASS_FS)
+ dev = dev_get_parent(dev);
+
+ return dev;
+}
+
static int ext4l_vfs_mount(struct udevice *dev)
{
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
struct fs_priv *uc_priv = dev_get_uclass_priv(dev);
struct fs_plat *plat = dev_get_uclass_plat(dev);
int ret;
@@ -52,7 +68,7 @@ static int ext4l_vfs_mount(struct udevice *dev)
if (!plat->desc)
return log_msg_ret("emd", -ENODEV);
- ret = ext4l_probe(plat->desc, &plat->part);
+ ret = ext4l_mount(&priv->state, plat->desc->bdev, &plat->part);
if (ret)
return log_msg_ret("emp", ret);
@@ -63,12 +79,13 @@ static int ext4l_vfs_mount(struct udevice *dev)
static int ext4l_vfs_unmount(struct udevice *dev)
{
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
struct fs_priv *uc_priv = dev_get_uclass_priv(dev);
if (!uc_priv->mounted)
return log_msg_ret("euu", -ENOTCONN);
- ext4l_close();
+ ext4l_umount(&priv->state);
uc_priv->mounted = false;
return 0;
@@ -92,28 +109,38 @@ static int ext4l_vfs_lookup_dir(struct udevice *dev, const char *path,
static int ext4l_vfs_ln(struct udevice *dev, const char *path,
const char *target)
{
- return ext4l_ln(target, path);
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
+
+ return ext4l_ln(&priv->state, target, path);
}
static int ext4l_vfs_rename(struct udevice *dev, const char *old_path,
const char *new_path)
{
- return ext4l_rename(old_path, new_path);
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
+
+ return ext4l_rename(&priv->state, old_path, new_path);
}
static int ext4l_vfs_statfs(struct udevice *dev, struct fs_statfs *stats)
{
- return ext4l_statfs(stats);
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
+
+ return ext4l_statfs(&priv->state, stats);
}
static int ext4l_vfs_unlink(struct udevice *dev, const char *path)
{
- return ext4l_unlink(path);
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
+
+ return ext4l_unlink(&priv->state, path);
}
static int ext4l_vfs_mkdir(struct udevice *dev, const char *path)
{
- return ext4l_mkdir(path);
+ struct ext4l_fs_priv *priv = dev_get_priv(dev);
+
+ return ext4l_mkdir(&priv->state, path);
}
static const struct fs_ops ext4l_vfs_ops = {
@@ -138,6 +165,8 @@ U_BOOT_DRIVER(ext4_fs) = {
static int ext4l_dir_open(struct udevice *dev, struct fs_dir_stream *strm)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dev);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct ext4l_dir_priv *priv = dev_get_priv(dev);
struct dir_uc_priv *uc_priv = dev_get_uclass_priv(dev);
struct fs_dir_stream *ext4_strm;
@@ -145,7 +174,7 @@ static int ext4l_dir_open(struct udevice *dev, struct fs_dir_stream *strm)
int ret;
path = *uc_priv->path ? uc_priv->path : "/";
- ret = ext4l_opendir(path, &ext4_strm);
+ ret = ext4l_opendir(&fspriv->state, path, &ext4_strm);
if (ret)
return log_msg_ret("edo", ret);
@@ -157,11 +186,13 @@ static int ext4l_dir_open(struct udevice *dev, struct fs_dir_stream *strm)
static int ext4l_dir_read(struct udevice *dev, struct fs_dir_stream *strm,
struct fs_dirent *dent)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dev);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct ext4l_dir_priv *priv = dev_get_priv(dev);
struct fs_dirent *ext4_dent;
int ret;
- ret = ext4l_readdir(priv->strm, &ext4_dent);
+ ret = ext4l_readdir(&fspriv->state, priv->strm, &ext4_dent);
if (ret)
return ret;
@@ -172,9 +203,11 @@ static int ext4l_dir_read(struct udevice *dev, struct fs_dir_stream *strm,
static int ext4l_dir_close(struct udevice *dev, struct fs_dir_stream *strm)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dev);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct ext4l_dir_priv *priv = dev_get_priv(dev);
- ext4l_closedir(priv->strm);
+ ext4l_closedir(&fspriv->state, priv->strm);
priv->strm = NULL;
return 0;
@@ -194,12 +227,15 @@ struct ext4l_file_priv {
static ssize_t ext4l_read_iter(struct udevice *dev, struct iov_iter *iter,
loff_t pos)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dev);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct ext4l_file_priv *priv = dev_get_priv(dev);
loff_t actual;
int ret;
- ret = ext4l_read(priv->path, iter_iov_ptr(iter), pos,
- iter_iov_avail(iter), &actual);
+ ret = ext4l_read(&fspriv->state, priv->path,
+ iter_iov_ptr(iter), pos, iter_iov_avail(iter),
+ &actual);
if (ret)
return log_msg_ret("efr", ret);
iter_advance(iter, actual);
@@ -210,11 +246,14 @@ static ssize_t ext4l_read_iter(struct udevice *dev, struct iov_iter *iter,
static ssize_t ext4l_write_iter(struct udevice *dev, struct iov_iter *iter,
loff_t pos)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dev);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct ext4l_file_priv *priv = dev_get_priv(dev);
loff_t actual;
int ret;
- ret = ext4l_write(priv->path, (void *)iter_iov_ptr(iter), pos,
+ ret = ext4l_write(&fspriv->state, priv->path,
+ (void *)iter_iov_ptr(iter), pos,
iter_iov_avail(iter), &actual);
if (ret)
return log_msg_ret("efw", ret);
@@ -239,6 +278,8 @@ static int ext4l_dir_open_file(struct udevice *dir, const char *leaf,
enum dir_open_flags_t oflags,
struct udevice **filp)
{
+ struct udevice *fsdev = ext4l_get_fs_dev(dir);
+ struct ext4l_fs_priv *fspriv = dev_get_priv(fsdev);
struct dir_uc_priv *uc_priv = dev_get_uclass_priv(dir);
struct ext4l_file_priv *priv;
struct udevice *dev;
@@ -253,9 +294,9 @@ static int ext4l_dir_open_file(struct udevice *dir, const char *leaf,
/* For read, verify the file exists and get its size */
if (oflags == DIR_O_RDONLY) {
- if (!ext4l_exists(path))
+ if (!ext4l_exists(&fspriv->state, path))
return log_msg_ret("eoe", -ENOENT);
- ret = ext4l_size(path, &size);
+ ret = ext4l_size(&fspriv->state, path, &size);
if (ret)
return log_msg_ret("eos", ret);
}
@@ -57,14 +57,15 @@ struct disk_partition *ext4l_get_partition(void)
/**
* ext4l_get_uuid() - Get the filesystem UUID
*
+ * @state: Per-mount state
* @uuid: Buffer to receive the 16-byte UUID
* Return: 0 on success, -ENODEV if not mounted
*/
-int ext4l_get_uuid(u8 *uuid)
+int ext4l_get_uuid(struct ext4l_state *state, u8 *uuid)
{
- if (!efs.sb)
+ if (!state->sb)
return -ENODEV;
- memcpy(uuid, efs.sb->s_uuid.b, 16);
+ memcpy(uuid, state->sb->s_uuid.b, 16);
return 0;
}
@@ -79,7 +80,7 @@ int ext4l_uuid(char *uuid_str)
u8 uuid[16];
int ret;
- ret = ext4l_get_uuid(uuid);
+ ret = ext4l_get_uuid_legacy(uuid);
if (ret)
return ret;
uuid_bin_to_str(uuid, uuid_str, UUID_STR_FORMAT_STD);
@@ -90,18 +91,19 @@ int ext4l_uuid(char *uuid_str)
/**
* ext4l_statfs() - Get filesystem statistics
*
+ * @state: Per-mount state
* @stats: Pointer to fs_statfs structure to fill
* Return: 0 on success, -ENODEV if not mounted
*/
-int ext4l_statfs(struct fs_statfs *stats)
+int ext4l_statfs(struct ext4l_state *state, struct fs_statfs *stats)
{
struct ext4_super_block *es;
- if (!efs.sb)
+ if (!state->sb)
return -ENODEV;
- es = EXT4_SB(efs.sb)->s_es;
- stats->bsize = efs.sb->s_blocksize;
+ es = EXT4_SB(state->sb)->s_es;
+ stats->bsize = state->sb->s_blocksize;
stats->blocks = ext4_blocks_count(es);
stats->bfree = ext4_free_blocks_count(es);
@@ -693,13 +695,15 @@ static int ext4l_resolve_path_internal(struct ext4l_state *state,
/**
* ext4l_resolve_path() - Resolve path to inode
*
+ * @state: Per-mount state
* @path: Path to resolve
* @inodep: Output inode pointer
* Return: 0 on success, negative on error
*/
-static int ext4l_resolve_path(const char *path, struct inode **inodep)
+static int ext4l_resolve_path(struct ext4l_state *state, const char *path,
+ struct inode **inodep)
{
- return ext4l_resolve_path_internal(&efs, path, inodep, 0);
+ return ext4l_resolve_path_internal(state, path, inodep, 0);
}
/**
@@ -743,14 +747,14 @@ static int ext4l_dir_actor(struct dir_context *ctx, const char *name,
return 0;
}
-int ext4l_ls(const char *dirname)
+int ext4l_ls(struct ext4l_state *state, const char *dirname)
{
struct inode *dir;
struct file file;
struct dir_context ctx;
int ret;
- ret = ext4l_resolve_path(dirname, &dir);
+ ret = ext4l_resolve_path(state, dirname, &dir);
if (ret)
return ret;
@@ -777,25 +781,26 @@ int ext4l_ls(const char *dirname)
return ret;
}
-int ext4l_exists(const char *filename)
+int ext4l_exists(struct ext4l_state *state, const char *filename)
{
struct inode *inode;
if (!filename)
return 0;
- if (ext4l_resolve_path(filename, &inode))
+ if (ext4l_resolve_path(state, filename, &inode))
return 0;
return 1;
}
-int ext4l_size(const char *filename, loff_t *sizep)
+int ext4l_size(struct ext4l_state *state, const char *filename,
+ loff_t *sizep)
{
struct inode *inode;
int ret;
- ret = ext4l_resolve_path(filename, &inode);
+ ret = ext4l_resolve_path(state, filename, &inode);
if (ret)
return ret;
@@ -804,8 +809,8 @@ int ext4l_size(const char *filename, loff_t *sizep)
return 0;
}
-int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actread)
+int ext4l_read(struct ext4l_state *state, const char *filename, void *buf,
+ loff_t offset, loff_t len, loff_t *actread)
{
uint copy_len, blk_off, blksize;
loff_t bytes_left, file_size;
@@ -817,7 +822,7 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
*actread = 0;
- ret = ext4l_resolve_path(filename, &inode);
+ ret = ext4l_resolve_path(state, filename, &inode);
if (ret) {
printf("** File not found %s **\n", filename);
return ret;
@@ -870,6 +875,29 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
return 0;
}
+/* Legacy wrappers that pass the global state */
+
+int ext4l_ls_legacy(const char *dirname)
+{
+ return ext4l_ls(&efs, dirname);
+}
+
+int ext4l_exists_legacy(const char *filename)
+{
+ return ext4l_exists(&efs, filename);
+}
+
+int ext4l_size_legacy(const char *filename, loff_t *sizep)
+{
+ return ext4l_size(&efs, filename, sizep);
+}
+
+int ext4l_read_legacy(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread)
+{
+ return ext4l_read(&efs, filename, buf, offset, len, actread);
+}
+
/**
* ext4l_resolve_file() - Resolve a file path for write operations
* @path: Path to process
@@ -883,7 +911,8 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
*
* Return: 0 on success, negative on error
*/
-static int ext4l_resolve_file(const char *path, struct dentry **dir_dentryp,
+static int ext4l_resolve_file(struct ext4l_state *state, const char *path,
+ struct dentry **dir_dentryp,
struct dentry **dentryp, char **path_copyp)
{
char *path_copy, *dir_path, *last_slash;
@@ -892,14 +921,14 @@ static int ext4l_resolve_file(const char *path, struct dentry **dir_dentryp,
const char *basename;
int ret;
- if (!efs.sb)
+ if (!state->sb)
return -ENODEV;
if (!path)
return -EINVAL;
/* Check if filesystem is mounted read-write */
- if (efs.sb->s_flags & SB_RDONLY)
+ if (state->sb->s_flags & SB_RDONLY)
return -EROFS;
/* Parse path to get parent directory and basename */
@@ -920,7 +949,7 @@ static int ext4l_resolve_file(const char *path, struct dentry **dir_dentryp,
}
/* Resolve parent directory */
- ret = ext4l_resolve_path(dir_path, &dir_inode);
+ ret = ext4l_resolve_path(state, dir_path, &dir_inode);
if (ret) {
free(path_copy);
return ret;
@@ -1119,8 +1148,8 @@ out_handle:
return ret;
}
-int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actwrite)
+int ext4l_write(struct ext4l_state *state, const char *filename, void *buf,
+ loff_t offset, loff_t len, loff_t *actwrite)
{
struct dentry *dir_dentry, *dentry;
char *path_copy;
@@ -1129,7 +1158,8 @@ int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len,
if (!buf || !actwrite)
return -EINVAL;
- ret = ext4l_resolve_file(filename, &dir_dentry, &dentry, &path_copy);
+ ret = ext4l_resolve_file(state, filename, &dir_dentry, &dentry,
+ &path_copy);
if (ret)
return ret;
@@ -1150,13 +1180,14 @@ int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len,
return ret;
}
-int ext4l_unlink(const char *filename)
+int ext4l_unlink(struct ext4l_state *state, const char *filename)
{
struct dentry *dentry, *dir_dentry;
char *path_copy;
int ret;
- ret = ext4l_resolve_file(filename, &dir_dentry, &dentry, &path_copy);
+ ret = ext4l_resolve_file(state, filename, &dir_dentry, &dentry,
+ &path_copy);
if (ret)
return ret;
@@ -1192,7 +1223,7 @@ int ext4l_unlink(const char *filename)
if (sync_ret)
ret = sync_ret;
/* Commit superblock with updated free counts */
- ext4_commit_super(efs.sb);
+ ext4_commit_super(state->sb);
}
out:
@@ -1202,13 +1233,14 @@ out:
return ret;
}
-int ext4l_mkdir(const char *dirname)
+int ext4l_mkdir(struct ext4l_state *state, const char *dirname)
{
struct dentry *dentry, *dir_dentry, *result;
char *path_copy;
int ret;
- ret = ext4l_resolve_file(dirname, &dir_dentry, &dentry, &path_copy);
+ ret = ext4l_resolve_file(state, dirname, &dir_dentry, &dentry,
+ &path_copy);
if (ret)
return ret;
@@ -1235,7 +1267,7 @@ int ext4l_mkdir(const char *dirname)
if (sync_ret)
ret = sync_ret;
/* Commit superblock with updated free counts */
- ext4_commit_super(efs.sb);
+ ext4_commit_super(state->sb);
}
out:
@@ -1245,7 +1277,8 @@ out:
return ret;
}
-int ext4l_ln(const char *filename, const char *linkname)
+int ext4l_ln(struct ext4l_state *state, const char *filename,
+ const char *linkname)
{
struct dentry *dentry, *dir_dentry;
char *path_copy;
@@ -1259,7 +1292,8 @@ int ext4l_ln(const char *filename, const char *linkname)
if (!filename)
return -EINVAL;
- ret = ext4l_resolve_file(linkname, &dir_dentry, &dentry, &path_copy);
+ ret = ext4l_resolve_file(state, linkname, &dir_dentry, &dentry,
+ &path_copy);
if (ret)
return ret;
@@ -1294,7 +1328,7 @@ int ext4l_ln(const char *filename, const char *linkname)
if (sync_ret)
ret = sync_ret;
/* Commit superblock with updated free counts */
- ext4_commit_super(efs.sb);
+ ext4_commit_super(state->sb);
}
out:
@@ -1305,7 +1339,8 @@ out:
return ret;
}
-int ext4l_rename(const char *old_path, const char *new_path)
+int ext4l_rename(struct ext4l_state *state, const char *old_path,
+ const char *new_path)
{
struct dentry *old_dentry, *new_dentry;
struct dentry *old_dir_dentry, *new_dir_dentry;
@@ -1316,7 +1351,7 @@ int ext4l_rename(const char *old_path, const char *new_path)
if (!new_path)
return -EINVAL;
- ret = ext4l_resolve_file(old_path, &old_dir_dentry, &old_dentry,
+ ret = ext4l_resolve_file(state, old_path, &old_dir_dentry, &old_dentry,
&old_path_copy);
if (ret)
return ret;
@@ -1327,7 +1362,7 @@ int ext4l_rename(const char *old_path, const char *new_path)
goto out_old;
}
- ret = ext4l_resolve_file(new_path, &new_dir_dentry, &new_dentry,
+ ret = ext4l_resolve_file(state, new_path, &new_dir_dentry, &new_dentry,
&new_path_copy);
if (ret)
goto out_old;
@@ -1345,7 +1380,7 @@ int ext4l_rename(const char *old_path, const char *new_path)
if (sync_ret)
ret = sync_ret;
/* Commit superblock with updated free counts */
- ext4_commit_super(efs.sb);
+ ext4_commit_super(state->sb);
}
out_new:
@@ -1478,16 +1513,17 @@ static int ext4l_opendir_actor(struct dir_context *ctx, const char *name,
return 1;
}
-int ext4l_opendir(const char *filename, struct fs_dir_stream **dirsp)
+int ext4l_opendir(struct ext4l_state *state, const char *filename,
+ struct fs_dir_stream **dirsp)
{
struct ext4l_dir *dir;
struct inode *inode;
int ret;
- if (!efs.mounted)
+ if (!state->mounted)
return -ENODEV;
- ret = ext4l_resolve_path(filename, &inode);
+ ret = ext4l_resolve_path(state, filename, &inode);
if (ret)
return ret;
@@ -1512,20 +1548,21 @@ int ext4l_opendir(const char *filename, struct fs_dir_stream **dirsp)
}
/* Increment open dir count to prevent unmount */
- efs.open_dirs++;
+ state->open_dirs++;
*dirsp = (struct fs_dir_stream *)dir;
return 0;
}
-int ext4l_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp)
+int ext4l_readdir(struct ext4l_state *state, struct fs_dir_stream *dirs,
+ struct fs_dirent **dentp)
{
struct ext4l_dir *dir = (struct ext4l_dir *)dirs;
struct ext4l_readdir_ctx ctx;
int ret;
- if (!efs.mounted)
+ if (!state->mounted)
return -ENODEV;
memset(&dir->dirent, '\0', sizeof(dir->dirent));
@@ -1557,7 +1594,7 @@ int ext4l_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp)
return 0;
}
-void ext4l_closedir(struct fs_dir_stream *dirs)
+void ext4l_closedir(struct ext4l_state *state, struct fs_dir_stream *dirs)
{
struct ext4l_dir *dir = (struct ext4l_dir *)dirs;
@@ -1568,6 +1605,59 @@ void ext4l_closedir(struct fs_dir_stream *dirs)
}
/* Decrement open dir count */
- if (efs.open_dirs > 0)
- efs.open_dirs--;
+ if (state->open_dirs > 0)
+ state->open_dirs--;
+}
+
+/* Legacy wrappers for write, dir, uuid, and statfs functions */
+
+int ext4l_get_uuid_legacy(u8 *uuid)
+{
+ return ext4l_get_uuid(&efs, uuid);
+}
+
+int ext4l_statfs_legacy(struct fs_statfs *stats)
+{
+ return ext4l_statfs(&efs, stats);
+}
+
+int ext4l_write_legacy(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actwrite)
+{
+ return ext4l_write(&efs, filename, buf, offset, len, actwrite);
+}
+
+int ext4l_unlink_legacy(const char *filename)
+{
+ return ext4l_unlink(&efs, filename);
+}
+
+int ext4l_mkdir_legacy(const char *dirname)
+{
+ return ext4l_mkdir(&efs, dirname);
+}
+
+int ext4l_ln_legacy(const char *filename, const char *linkname)
+{
+ return ext4l_ln(&efs, filename, linkname);
+}
+
+int ext4l_rename_legacy(const char *old_path, const char *new_path)
+{
+ return ext4l_rename(&efs, old_path, new_path);
+}
+
+int ext4l_opendir_legacy(const char *filename, struct fs_dir_stream **dirsp)
+{
+ return ext4l_opendir(&efs, filename, dirsp);
+}
+
+int ext4l_readdir_legacy(struct fs_dir_stream *dirs, struct fs_dirent **dentp)
+{
+ return ext4l_readdir(&efs, dirs, dentp);
+}
+
+void ext4l_closedir_legacy(struct fs_dir_stream *dirs)
+{
+ ext4l_closedir(&efs, dirs);
}
@@ -279,20 +279,20 @@ static struct fstype_info fstypes[] = {
.null_dev_desc_ok = false,
.probe = ext4l_probe,
.close = ext4l_close,
- .ls = ext4l_ls,
- .exists = ext4l_exists,
- .size = ext4l_size,
- .read = ext4l_read,
- .write = ext4l_op_ptr(ext4l_write, fs_write_unsupported),
+ .ls = ext4l_ls_legacy,
+ .exists = ext4l_exists_legacy,
+ .size = ext4l_size_legacy,
+ .read = ext4l_read_legacy,
+ .write = ext4l_op_ptr(ext4l_write_legacy, fs_write_unsupported),
.uuid = ext4l_uuid,
- .opendir = ext4l_opendir,
- .readdir = ext4l_readdir,
- .closedir = ext4l_closedir,
- .unlink = ext4l_op_ptr(ext4l_unlink, fs_unlink_unsupported),
- .mkdir = ext4l_op_ptr(ext4l_mkdir, fs_mkdir_unsupported),
- .ln = ext4l_op_ptr(ext4l_ln, fs_ln_unsupported),
- .rename = ext4l_op_ptr(ext4l_rename, fs_rename_unsupported),
- .statfs = ext4l_statfs,
+ .opendir = ext4l_opendir_legacy,
+ .readdir = ext4l_readdir_legacy,
+ .closedir = ext4l_closedir_legacy,
+ .unlink = ext4l_op_ptr(ext4l_unlink_legacy, fs_unlink_unsupported),
+ .mkdir = ext4l_op_ptr(ext4l_mkdir_legacy, fs_mkdir_unsupported),
+ .ln = ext4l_op_ptr(ext4l_ln_legacy, fs_ln_unsupported),
+ .rename = ext4l_op_ptr(ext4l_rename_legacy, fs_rename_unsupported),
+ .statfs = ext4l_statfs_legacy,
},
#endif
#if IS_ENABLED(CONFIG_SANDBOX) && !IS_ENABLED(CONFIG_XPL_BUILD)
@@ -76,46 +76,41 @@ void ext4l_umount(struct ext4l_state *state);
*/
void ext4l_close(void);
-/**
- * ext4l_ls() - List directory contents
- *
- * @dirname: Directory path to list
- * Return: 0 on success, negative on error
- */
-int ext4l_ls(const char *dirname);
-
-/**
- * ext4l_exists() - Check if a file or directory exists
- *
- * @filename: Path to check
- * Return: 1 if exists, 0 if not
- */
-int ext4l_exists(const char *filename);
-
-/**
- * ext4l_size() - Get the size of a file
- *
- * @filename: Path to file
- * @sizep: Returns the file size
- * Return: 0 on success, negative on error
- */
-int ext4l_size(const char *filename, loff_t *sizep);
-
-/**
- * ext4l_read() - Read data from a file
- *
- * @filename: Path to file
- * @buf: Buffer to read data into
- * @offset: Byte offset to start reading from
- * @len: Number of bytes to read (0 = read entire file from offset)
- * @actread: Returns actual bytes read
- * Return: 0 on success, negative on error
- */
-int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actread);
-
-/**
- * ext4l_write() - Write data to a file
+/* State-aware functions for VFS callers */
+int ext4l_ls(struct ext4l_state *state, const char *dirname);
+int ext4l_exists(struct ext4l_state *state, const char *filename);
+int ext4l_size(struct ext4l_state *state, const char *filename,
+ loff_t *sizep);
+int ext4l_read(struct ext4l_state *state, const char *filename,
+ void *buf, loff_t offset, loff_t len, loff_t *actread);
+
+/* Legacy wrappers using the global state */
+int ext4l_ls_legacy(const char *dirname);
+int ext4l_exists_legacy(const char *filename);
+int ext4l_size_legacy(const char *filename, loff_t *sizep);
+int ext4l_read_legacy(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread);
+
+/* State-aware functions for remaining operations */
+int ext4l_get_uuid(struct ext4l_state *state, u8 *uuid);
+int ext4l_statfs(struct ext4l_state *state, struct fs_statfs *stats);
+int ext4l_write(struct ext4l_state *state, const char *filename,
+ void *buf, loff_t offset, loff_t len, loff_t *actwrite);
+int ext4l_unlink(struct ext4l_state *state, const char *filename);
+int ext4l_mkdir(struct ext4l_state *state, const char *dirname);
+int ext4l_ln(struct ext4l_state *state, const char *filename,
+ const char *linkname);
+int ext4l_rename(struct ext4l_state *state, const char *old_path,
+ const char *new_path);
+int ext4l_opendir(struct ext4l_state *state, const char *filename,
+ struct fs_dir_stream **dirsp);
+int ext4l_readdir(struct ext4l_state *state, struct fs_dir_stream *dirs,
+ struct fs_dirent **dentp);
+void ext4l_closedir(struct ext4l_state *state,
+ struct fs_dir_stream *dirs);
+
+/**
+ * ext4l_write_legacy() - Write data to a file
*
* Creates the file if it doesn't exist. Overwrites existing content.
*
@@ -127,30 +122,30 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len,
* Return: 0 on success, -EROFS if read-only, -ENODEV if not mounted,
* -ENOTDIR if parent is not a directory, negative on other errors
*/
-int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actwrite);
+int ext4l_write_legacy(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actwrite);
/**
- * ext4l_unlink() - Delete a file
+ * ext4l_unlink_legacy() - Delete a file
*
* @filename: Path to file to delete
* Return: 0 on success, -ENOENT if file not found, -EISDIR if path is a
* directory, -EROFS if read-only, negative on other errors
*/
-int ext4l_unlink(const char *filename);
+int ext4l_unlink_legacy(const char *filename);
/**
- * ext4l_mkdir() - Create a directory
+ * ext4l_mkdir_legacy() - Create a directory
*
* @dirname: Path of directory to create
* Return: 0 on success, -EEXIST if directory already exists,
* -ENOTDIR if parent is not a directory, -EROFS if read-only,
* negative on other errors
*/
-int ext4l_mkdir(const char *dirname);
+int ext4l_mkdir_legacy(const char *dirname);
/**
- * ext4l_ln() - Create a symbolic link
+ * ext4l_ln_legacy() - Create a symbolic link
*
* Creates the symlink, replacing any existing file (like ln -sf).
* Refuses to replace a directory.
@@ -161,10 +156,10 @@ int ext4l_mkdir(const char *dirname);
* -ENOTDIR if parent is not a directory, -EROFS if read-only,
* negative on other errors
*/
-int ext4l_ln(const char *filename, const char *target);
+int ext4l_ln_legacy(const char *filename, const char *target);
/**
- * ext4l_rename() - Rename a file or directory
+ * ext4l_rename_legacy() - Rename a file or directory
*
* @old_path: Current path of file or directory
* @new_path: New path for file or directory
@@ -172,15 +167,15 @@ int ext4l_ln(const char *filename, const char *target);
* -ENOTDIR if parent is not a directory, -EROFS if read-only,
* negative on other errors
*/
-int ext4l_rename(const char *old_path, const char *new_path);
+int ext4l_rename_legacy(const char *old_path, const char *new_path);
/**
- * ext4l_get_uuid() - Get the filesystem UUID
+ * ext4l_get_uuid_legacy() - Get the filesystem UUID
*
* @uuid: Buffer to receive the 16-byte UUID
* Return: 0 on success, -ENODEV if not mounted
*/
-int ext4l_get_uuid(u8 *uuid);
+int ext4l_get_uuid_legacy(u8 *uuid);
/**
* ext4l_uuid() - Get the filesystem UUID as a string
@@ -191,37 +186,37 @@ int ext4l_get_uuid(u8 *uuid);
int ext4l_uuid(char *uuid_str);
/**
- * ext4l_statfs() - Get filesystem statistics
+ * ext4l_statfs_legacy() - Get filesystem statistics
*
* @stats: Pointer to fs_statfs structure to fill
* Return: 0 on success, -ENODEV if not mounted
*/
-int ext4l_statfs(struct fs_statfs *stats);
+int ext4l_statfs_legacy(struct fs_statfs *stats);
/**
- * ext4l_opendir() - Open a directory for iteration
+ * ext4l_opendir_legacy() - Open a directory for iteration
*
* @filename: Directory path
* @dirsp: Returns directory stream pointer
* Return: 0 on success, -ENODEV if not mounted, -ENOTDIR if not a directory,
* -ENOMEM on allocation failure
*/
-int ext4l_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int ext4l_opendir_legacy(const char *filename, struct fs_dir_stream **dirsp);
/**
- * ext4l_readdir() - Read the next directory entry
+ * ext4l_readdir_legacy() - Read the next directory entry
*
- * @dirs: Directory stream from ext4l_opendir
+ * @dirs: Directory stream from ext4l_opendir_legacy
* @dentp: Returns pointer to directory entry
* Return: 0 on success, -ENODEV if not mounted, -ENOENT at end of directory
*/
-int ext4l_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int ext4l_readdir_legacy(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
/**
- * ext4l_closedir() - Close a directory stream
+ * ext4l_closedir_legacy() - Close a directory stream
*
* @dirs: Directory stream to close
*/
-void ext4l_closedir(struct fs_dir_stream *dirs);
+void ext4l_closedir_legacy(struct fs_dir_stream *dirs);
#endif /* __EXT4L_H__ */
@@ -63,7 +63,7 @@ static int fs_test_ext4l_msgs_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Get the UUID and clear the env var now we have the output */
- ut_assertok(ext4l_get_uuid(uuid));
+ ut_assertok(ext4l_get_uuid_legacy(uuid));
uuid_bin_to_str(uuid, uuid_str, UUID_STR_FORMAT_STD);
ut_assertok(env_set("ext4l_msgs", NULL));
@@ -142,11 +142,11 @@ static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Open root directory */
- ut_assertok(ext4l_opendir("/", &dirs));
+ ut_assertok(ext4l_opendir_legacy("/", &dirs));
ut_assertnonnull(dirs);
/* Iterate through entries */
- while (!ext4l_readdir(dirs, &dent)) {
+ while (!ext4l_readdir_legacy(dirs, &dent)) {
ut_assertnonnull(dent);
count++;
if (!strcmp(dent->name, "testfile.txt")) {
@@ -162,7 +162,7 @@ static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts)
}
}
- ext4l_closedir(dirs);
+ ext4l_closedir_legacy(dirs);
/* Verify we found expected entries */
ut_assert(found_testfile);
@@ -173,11 +173,11 @@ static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts)
/* Now test reading the subdirectory */
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
- ut_assertok(ext4l_opendir("/subdir", &dirs));
+ ut_assertok(ext4l_opendir_legacy("/subdir", &dirs));
ut_assertnonnull(dirs);
count = 0;
- while (!ext4l_readdir(dirs, &dent)) {
+ while (!ext4l_readdir_legacy(dirs, &dent)) {
ut_assertnonnull(dent);
count++;
if (!strcmp(dent->name, "nested.txt")) {
@@ -187,7 +187,7 @@ static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts)
}
}
- ext4l_closedir(dirs);
+ ext4l_closedir_legacy(dirs);
ut_assert(found_nested);
/* At least ., .., nested.txt */
@@ -199,9 +199,9 @@ FS_TEST_ARGS(fs_test_ext4l_opendir_norun, UTF_SCAN_FDT | UTF_CONSOLE |
UTF_MANUAL, { "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_exists_norun() - Test ext4l_exists function
+ * fs_test_ext4l_exists_norun() - Test ext4l_exists_legacy function
*
- * Verifies that ext4l_exists correctly reports file existence.
+ * Verifies that ext4l_exists_legacy correctly reports file existence.
*
* Arguments:
* fs_image: Path to the ext4 filesystem image
@@ -215,10 +215,10 @@ static int fs_test_ext4l_exists_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Test existing directory */
- ut_asserteq(1, ext4l_exists("/"));
+ ut_asserteq(1, ext4l_exists_legacy("/"));
/* Test non-existent paths */
- ut_asserteq(0, ext4l_exists("/no/such/path"));
+ ut_asserteq(0, ext4l_exists_legacy("/no/such/path"));
return 0;
}
@@ -226,9 +226,9 @@ FS_TEST_ARGS(fs_test_ext4l_exists_norun, UTF_SCAN_FDT | UTF_CONSOLE |
UTF_MANUAL, { "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_size_norun() - Test ext4l_size function
+ * fs_test_ext4l_size_norun() - Test ext4l_size_legacy function
*
- * Verifies that ext4l_size correctly reports file size.
+ * Verifies that ext4l_size_legacy correctly reports file size.
*
* Arguments:
* fs_image: Path to the ext4 filesystem image
@@ -243,15 +243,15 @@ static int fs_test_ext4l_size_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Test root directory size - one block on a 4K block filesystem */
- ut_assertok(ext4l_size("/", &size));
+ ut_assertok(ext4l_size_legacy("/", &size));
ut_asserteq(SZ_4K, size);
/* Test file size - testfile.txt contains "hello world\n" */
- ut_assertok(ext4l_size("/testfile.txt", &size));
+ ut_assertok(ext4l_size_legacy("/testfile.txt", &size));
ut_asserteq(12, size);
/* Test non-existent path returns -ENOENT */
- ut_asserteq(-ENOENT, ext4l_size("/no/such/path", &size));
+ ut_asserteq(-ENOENT, ext4l_size_legacy("/no/such/path", &size));
return 0;
}
@@ -259,7 +259,7 @@ FS_TEST_ARGS(fs_test_ext4l_size_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL,
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_read_norun() - Test ext4l_read function
+ * fs_test_ext4l_read_norun() - Test ext4l_read_legacy function
*
* Verifies that ext4l can read file contents.
*
@@ -278,18 +278,20 @@ static int fs_test_ext4l_read_norun(struct unit_test_state *uts)
/* Read the test file - contains "hello world\n" (12 bytes) */
memset(buf, '\0', sizeof(buf));
- ut_assertok(ext4l_read("/testfile.txt", buf, 0, 0, &actread));
+ ut_assertok(ext4l_read_legacy("/testfile.txt", buf, 0, 0, &actread));
ut_asserteq(12, actread);
ut_asserteq_str("hello world\n", buf);
/* Test partial read with offset */
memset(buf, '\0', sizeof(buf));
- ut_assertok(ext4l_read("/testfile.txt", buf, 6, 5, &actread));
+ ut_assertok(ext4l_read_legacy("/testfile.txt", buf, 6, 5, &actread));
ut_asserteq(5, actread);
ut_asserteq_str("world", buf);
/* Verify read returns error for non-existent path */
- ut_asserteq(-ENOENT, ext4l_read("/no/such/file", buf, 0, 10, &actread));
+ ut_asserteq(-ENOENT,
+ ext4l_read_legacy("/no/such/file", buf, 0, 10,
+ &actread));
return 0;
}
@@ -345,7 +347,7 @@ static int fs_test_ext4l_fsinfo_norun(struct unit_test_state *uts)
ut_assertnonnull(fs_image);
ut_assertok(run_commandf("host bind 0 %s", fs_image));
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
- ut_assertok(ext4l_statfs(&stats));
+ ut_assertok(ext4l_statfs_legacy(&stats));
used = stats.blocks - stats.bfree;
console_record_reset_enable();
@@ -367,7 +369,7 @@ FS_TEST_ARGS(fs_test_ext4l_fsinfo_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_statfs_norun() - Test ext4l_statfs function
+ * fs_test_ext4l_statfs_norun() - Test ext4l_statfs_legacy function
*
* Verifies that ext4l can return filesystem statistics.
*
@@ -384,7 +386,7 @@ static int fs_test_ext4l_statfs_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Get filesystem statistics */
- ut_assertok(ext4l_statfs(&stats));
+ ut_assertok(ext4l_statfs_legacy(&stats));
/* Verify reasonable values for a 64MB filesystem */
ut_asserteq(SZ_4K, stats.bsize);
@@ -398,7 +400,7 @@ FS_TEST_ARGS(fs_test_ext4l_statfs_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_write_norun() - Test ext4l_write function
+ * fs_test_ext4l_write_norun() - Test ext4l_write_legacy function
*
* Verifies that ext4l can write file contents to the filesystem.
*
@@ -419,18 +421,19 @@ static int fs_test_ext4l_write_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Write a new file */
- ut_assertok(ext4l_write("/newfile.txt", (void *)test_data, 0,
- test_len, &actwrite));
+ ut_assertok(ext4l_write_legacy("/newfile.txt", (void *)test_data,
+ 0, test_len, &actwrite));
ut_asserteq(test_len, actwrite);
/* Verify the file exists and has correct size */
- ut_asserteq(1, ext4l_exists("/newfile.txt"));
- ut_assertok(ext4l_size("/newfile.txt", &size));
+ ut_asserteq(1, ext4l_exists_legacy("/newfile.txt"));
+ ut_assertok(ext4l_size_legacy("/newfile.txt", &size));
ut_asserteq(test_len, size);
/* Read back and verify contents */
memset(read_buf, '\0', sizeof(read_buf));
- ut_assertok(ext4l_read("/newfile.txt", read_buf, 0, 0, &actread));
+ ut_assertok(ext4l_read_legacy("/newfile.txt", read_buf, 0, 0,
+ &actread));
ut_asserteq(test_len, actread);
ut_asserteq_str(test_data, read_buf);
@@ -440,7 +443,7 @@ FS_TEST_ARGS(fs_test_ext4l_write_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL,
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_unlink_norun() - Test ext4l_unlink function
+ * fs_test_ext4l_unlink_norun() - Test ext4l_unlink_legacy function
*
* Verifies that ext4l can delete files from the filesystem.
*
@@ -459,21 +462,21 @@ static int fs_test_ext4l_unlink_norun(struct unit_test_state *uts)
ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY));
/* Create a new file to unlink */
- ut_assertok(ext4l_write("/unlinkme.txt", (void *)test_data, 0,
- test_len, &actwrite));
+ ut_assertok(ext4l_write_legacy("/unlinkme.txt", (void *)test_data,
+ 0, test_len, &actwrite));
ut_asserteq(test_len, actwrite);
/* Verify file exists (same mount) */
- ut_asserteq(1, ext4l_exists("/unlinkme.txt"));
+ ut_asserteq(1, ext4l_exists_legacy("/unlinkme.txt"));
/* Unlink the file */
- ut_assertok(ext4l_unlink("/unlinkme.txt"));
+ ut_assertok(ext4l_unlink_legacy("/unlinkme.txt"));
/* Verify file no longer exists */
- ut_asserteq(0, ext4l_exists("/unlinkme.txt"));
+ ut_asserteq(0, ext4l_exists_legacy("/unlinkme.txt"));
/* Verify unlinking non-existent file returns -ENOENT */
- ut_asserteq(-ENOENT, ext4l_unlink("/nonexistent"));
+ ut_asserteq(-ENOENT, ext4l_unlink_legacy("/nonexistent"));
return 0;
}
@@ -481,7 +484,7 @@ FS_TEST_ARGS(fs_test_ext4l_unlink_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_mkdir_norun() - Test ext4l_mkdir function
+ * fs_test_ext4l_mkdir_norun() - Test ext4l_mkdir_legacy function
*
* Verifies that ext4l can create directories on the filesystem.
*
@@ -506,21 +509,21 @@ static int fs_test_ext4l_mkdir_norun(struct unit_test_state *uts)
test_counter++;
/* Create a new directory */
- ret = ext4l_mkdir(dir_name);
+ ret = ext4l_mkdir_legacy(dir_name);
ut_assertok(ret);
/* Verify directory exists */
- ut_asserteq(1, ext4l_exists(dir_name));
+ ut_asserteq(1, ext4l_exists_legacy(dir_name));
/* Verify creating duplicate returns -EEXIST */
- ut_asserteq(-EEXIST, ext4l_mkdir(dir_name));
+ ut_asserteq(-EEXIST, ext4l_mkdir_legacy(dir_name));
/* Create nested directory */
- ut_assertok(ext4l_mkdir(subdir_name));
- ut_asserteq(1, ext4l_exists(subdir_name));
+ ut_assertok(ext4l_mkdir_legacy(subdir_name));
+ ut_asserteq(1, ext4l_exists_legacy(subdir_name));
/* Verify creating directory in non-existent parent returns -ENOENT */
- ut_asserteq(-ENOENT, ext4l_mkdir("/nonexistent/dir"));
+ ut_asserteq(-ENOENT, ext4l_mkdir_legacy("/nonexistent/dir"));
return 0;
}
@@ -528,7 +531,7 @@ FS_TEST_ARGS(fs_test_ext4l_mkdir_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL,
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_ln_norun() - Test ext4l_ln function
+ * fs_test_ext4l_ln_norun() - Test ext4l_ln_legacy function
*
* Verifies that ext4l can create symbolic links on the filesystem.
*
@@ -554,33 +557,33 @@ static int fs_test_ext4l_ln_norun(struct unit_test_state *uts)
test_counter++;
/*
- * Create a symbolic link. ext4l_ln follows U-Boot's ln command
- * convention: ext4l_ln(target, linkname) creates linkname pointing
- * to target.
+ * Create a symbolic link. ext4l_ln_legacy follows U-Boot's ln command
+ * convention: ext4l_ln_legacy(target, linkname) creates linkname
+ * pointing to target.
*/
- ut_assertok(ext4l_ln(target, link_name));
+ ut_assertok(ext4l_ln_legacy(target, link_name));
/* Verify symlink exists */
- ut_asserteq(1, ext4l_exists(link_name));
+ ut_asserteq(1, ext4l_exists_legacy(link_name));
/*
* Size through symlink should be target file's size (12 bytes),
* since ext4l_resolve_path follows symlinks (like stat, not lstat)
*/
- ut_assertok(ext4l_size(link_name, &size));
+ ut_assertok(ext4l_size_legacy(link_name, &size));
ut_asserteq(12, size);
/* Verify we can read through the symlink */
memset(buf, '\0', sizeof(buf));
- ut_assertok(ext4l_read(link_name, buf, 0, 0, &actread));
+ ut_assertok(ext4l_read_legacy(link_name, buf, 0, 0, &actread));
ut_asserteq(12, actread);
ut_asserteq_str("hello world\n", buf);
/* Verify creating duplicate succeeds (like ln -sf) */
- ut_assertok(ext4l_ln(target, link_name));
+ ut_assertok(ext4l_ln_legacy(target, link_name));
/* Verify creating symlink in non-existent parent returns -ENOENT */
- ut_asserteq(-ENOENT, ext4l_ln(target, "/nonexistent/link"));
+ ut_asserteq(-ENOENT, ext4l_ln_legacy(target, "/nonexistent/link"));
return 0;
}
@@ -588,7 +591,7 @@ FS_TEST_ARGS(fs_test_ext4l_ln_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL,
{ "fs_image", UT_ARG_STR });
/**
- * fs_test_ext4l_rename_norun() - Test ext4l_rename function
+ * fs_test_ext4l_rename_norun() - Test ext4l_rename_legacy function
*
* Verifies that ext4l can rename files and directories on the filesystem.
*
@@ -616,32 +619,32 @@ static int fs_test_ext4l_rename_norun(struct unit_test_state *uts)
test_counter++;
/* Create a file to rename */
- ut_assertok(ext4l_write(old_name, (void *)test_data, 0,
- test_len, &actwrite));
+ ut_assertok(ext4l_write_legacy(old_name, (void *)test_data,
+ 0, test_len, &actwrite));
ut_asserteq(test_len, actwrite);
/* Verify file exists */
- ut_asserteq(1, ext4l_exists(old_name));
+ ut_asserteq(1, ext4l_exists_legacy(old_name));
/* Rename the file */
- ut_assertok(ext4l_rename(old_name, new_name));
+ ut_assertok(ext4l_rename_legacy(old_name, new_name));
/* Verify old name no longer exists, new name does */
- ut_asserteq(0, ext4l_exists(old_name));
- ut_asserteq(1, ext4l_exists(new_name));
+ ut_asserteq(0, ext4l_exists_legacy(old_name));
+ ut_asserteq(1, ext4l_exists_legacy(new_name));
/* Verify file size is preserved */
- ut_assertok(ext4l_size(new_name, &size));
+ ut_assertok(ext4l_size_legacy(new_name, &size));
ut_asserteq(test_len, size);
/* Verify renaming non-existent file returns -ENOENT */
- ut_asserteq(-ENOENT, ext4l_rename("/nonexistent", "/newname"));
+ ut_asserteq(-ENOENT, ext4l_rename_legacy("/nonexistent", "/newname"));
/* Test cross-directory rename */
- ut_assertok(ext4l_mkdir(subdir_name));
- ut_assertok(ext4l_rename(new_name, moved_name));
- ut_asserteq(0, ext4l_exists(new_name));
- ut_asserteq(1, ext4l_exists(moved_name));
+ ut_assertok(ext4l_mkdir_legacy(subdir_name));
+ ut_assertok(ext4l_rename_legacy(new_name, moved_name));
+ ut_asserteq(0, ext4l_exists_legacy(new_name));
+ ut_asserteq(1, ext4l_exists_legacy(moved_name));
return 0;
}