Skip to contentSkip to conversation

efi_loader: file: set a backend block device for file operations

PATCH New AKASHI Takahiro 2 participants 3 messages Feb 28, 2020 – Mar 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_loader: file: set a backend block device for file operations

In the current implementation, set_blk_dev() is called in opening a file, but not in opening a directory. This will cause failures at succeeding directory operations as the "current" block device remains nullified. Adding set_blk_dev() fixes this issue.

---
 lib/efi_loader/efi_file.c | 3 +++
 1 file changed, 3 insertions(+)
lib/efi_loader/efi_file.c +3 -0
index 140116ddc4ac..ba55b2829e03 100644
@@ -235,6 +235,9 @@ static struct efi_file_handle *file_open(struct file_system *fs,
 	} else {
 		fh->isdir = 1;
 		strcpy(fh->path, "");
+
+		if (set_blk_dev(fh))
+			goto error;
 	}
 
 	return &fh->base;
Signature · 1 line
2.24.0
#1 lore raw

PATCH 1/1 efi_loader: file: set a backend block device for file operations

Quoted 15 lines · AKASHI Takahiro

In the current implementation, set_blk_dev() is called in opening a file, but not in opening a directory. This will cause failures at succeeding directory operations as the "current" block device remains nullified. Adding set_blk_dev() fixes this issue.

---
  lib/efi_loader/efi_file.c | 3 +++
  1 file changed, 3 insertions(+)
lib/efi_loader/efi_file.c +0 -0
index 140116ddc4ac..ba55b2829e03 100644

lib/efi_loader/efi_file.c static struct efi_file_handle *file_open(struct file_system *fs, · line 240

Quoted 6 lines
lib/efi_loader/efi_file.c +3 -0
@@ -235,6 +235,9 @@ static struct efi_file_handle *file_open(struct file_system *fs,
  	} else {
  		fh->isdir = 1;
  		strcpy(fh->path, "");
+
+		if (set_blk_dev(fh))
+			goto error;

In the 'true' path of the if statement is_dir() results in fs_type = FS_TYPE_ANY. It would be inconsistent to call set_blk_dev() here.

Which "succeeding directory operation" does not call set_blk_dev(fh)?

Where did you observe an error?

Best regards

Heinrich

Quoted 4 lines
lib/efi_loader/efi_file.c +0 -0
  	}
 
  	return &fh->base;
#2 lore raw

PATCH 1/1 efi_loader: file: set a backend block device for file operations

Quoted 26 lines · Heinrich Schuchardt
Quoted 15 lines · AKASHI Takahiro

In the current implementation, set_blk_dev() is called in opening a file, but not in opening a directory. This will cause failures at succeeding directory operations as the "current" block device remains nullified. Adding set_blk_dev() fixes this issue.

---
  lib/efi_loader/efi_file.c | 3 +++
  1 file changed, 3 insertions(+)
lib/efi_loader/efi_file.c +0 -0
index 140116ddc4ac..ba55b2829e03 100644

lib/efi_loader/efi_file.c static struct efi_file_handle *file_open(struct file_system *fs, · line 240

Quoted 6 lines
lib/efi_loader/efi_file.c +3 -0
@@ -235,6 +235,9 @@ static struct efi_file_handle *file_open(struct file_system *fs,
  	} else {
  		fh->isdir = 1;
  		strcpy(fh->path, "");
+
+		if (set_blk_dev(fh))
+			goto error;

In the 'true' path of the if statement is_dir() results in fs_type = FS_TYPE_ANY. It would be inconsistent to call set_blk_dev() here.

Quoted 3 lines

Which "succeeding directory operation" does not call set_blk_dev(fh)?

Where did you observe an error?

Ah, it would be better to fix my code as I had a mixed use of efi interface, open_volume(), and U-Boot interfaces, like fs_opendir()/ readdir().

Thanks,
-Takahiro Akashi

Quoted 9 lines

Best regards

Heinrich

Quoted 4 lines
lib/efi_loader/efi_file.c +0 -0
  	}
 
  	return &fh->base;