]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - fs/sandbox/sandboxfs.c
2 * Copyright (c) 2012, Google Inc.
4 * SPDX-License-Identifier: GPL-2.0+
11 int sandbox_fs_set_blk_dev(block_dev_desc_t
*rbdd
, disk_partition_t
*info
)
16 long sandbox_fs_read_at(const char *filename
, unsigned long pos
,
17 void *buffer
, unsigned long maxsize
)
22 fd
= os_open(filename
, OS_O_RDONLY
);
25 ret
= os_lseek(fd
, pos
, OS_SEEK_SET
);
31 maxsize
= os_get_filesize(filename
);
32 size
= os_read(fd
, buffer
, maxsize
);
38 long sandbox_fs_write_at(const char *filename
, unsigned long pos
,
39 void *buffer
, unsigned long towrite
)
44 fd
= os_open(filename
, OS_O_RDWR
| OS_O_CREAT
);
47 ret
= os_lseek(fd
, pos
, OS_SEEK_SET
);
52 size
= os_write(fd
, buffer
, towrite
);
58 int sandbox_fs_ls(const char *dirname
)
60 struct os_dirent_node
*head
, *node
;
63 ret
= os_dirent_ls(dirname
, &head
);
67 for (node
= head
; node
; node
= node
->next
) {
68 printf("%s %10lu %s\n", os_dirent_get_typename(node
->type
),
69 node
->size
, node
->name
);
75 int sandbox_fs_exists(const char *filename
)
79 sz
= os_get_filesize(filename
);
83 void sandbox_fs_close(void)
87 int fs_read_sandbox(const char *filename
, void *buf
, int offset
, int len
)
91 len_read
= sandbox_fs_read_at(filename
, offset
, buf
, len
);
93 printf("** Unable to read file %s **\n", filename
);
100 int fs_write_sandbox(const char *filename
, void *buf
, int offset
, int len
)
104 len_written
= sandbox_fs_write_at(filename
, offset
, buf
, len
);
105 if (len_written
== -1) {
106 printf("** Unable to write file %s **\n", filename
);