mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-18 19:04:38 +00:00
fs: ubifs: Add volume mounted check
Safety guard in the U-Boot filesystem glue code, because these functions are called from different parts of the codebase. For generic filesystem handling this should have been checked in blk_get_device_part_str() already. Commands from cmd/ubifs.c should also check this before calling those functions, but you never know?! Signed-off-by: Alexander Dahl <ada@thorsis.com>
This commit is contained in:
parent
0989033d09
commit
ca1f11d8c1
1 changed files with 20 additions and 0 deletions
|
@ -621,6 +621,11 @@ int ubifs_ls(const char *filename)
|
|||
unsigned long inum;
|
||||
int ret = 0;
|
||||
|
||||
if (!ubifs_is_mounted()) {
|
||||
debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
inum = ubifs_findfile(ubifs_sb, (char *)filename);
|
||||
if (!inum) {
|
||||
ret = -1;
|
||||
|
@ -661,6 +666,11 @@ int ubifs_exists(const char *filename)
|
|||
{
|
||||
unsigned long inum;
|
||||
|
||||
if (!ubifs_is_mounted()) {
|
||||
debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
inum = ubifs_findfile(ubifs_sb, (char *)filename);
|
||||
|
||||
return inum != 0;
|
||||
|
@ -672,6 +682,11 @@ int ubifs_size(const char *filename, loff_t *size)
|
|||
struct inode *inode;
|
||||
int err = 0;
|
||||
|
||||
if (!ubifs_is_mounted()) {
|
||||
debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
inum = ubifs_findfile(ubifs_sb, (char *)filename);
|
||||
if (!inum) {
|
||||
err = -1;
|
||||
|
@ -875,6 +890,11 @@ int ubifs_read(const char *filename, void *buf, loff_t offset,
|
|||
int count;
|
||||
int last_block_size = 0;
|
||||
|
||||
if (!ubifs_is_mounted()) {
|
||||
debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*actread = 0;
|
||||
|
||||
if (offset & (PAGE_SIZE - 1)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue