[v1,6/6] lib/efi: Add check for ioctl_iflags support

Message ID 6bac383be03d9d2219306f03b0d8421558ef732a.1533686335.git.geoff@infradead.org
State Accepted
Headers show
Series
  • [v1,1/6] docker: Add strace for interactive debugging
Related show

Commit Message

Geoff Levand Aug. 8, 2018, 12:01 a.m.
The efi tests may use a filesystem which does not support
ioctl_iflags.  Add a check and skip the ioctl_iflags
operations if not supported.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 lib/efi/efivar.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/efi/efivar.c b/lib/efi/efivar.c
index 21c5d34..91b2507 100644
--- a/lib/efi/efivar.c
+++ b/lib/efi/efivar.c
@@ -83,17 +83,32 @@  int efi_del_variable(const char *guidstr, const char *name)
 		return -1;
 
 	rc = ioctl(fd, FS_IOC_GETFLAGS, &flag);
-	if (rc == -1)
+	if (rc == -1 && errno == ENOTTY) {
+		pb_debug_fn("'%s' does not support ioctl_iflags.\n",
+			efivarfs_path);
+		goto delete;
+	} else if (rc == -1) {
+		pb_log_fn("FS_IOC_GETFLAGS failed: (%d) %s\n", errno,
+			strerror(errno));
 		goto exit;
+	}
 
 	flag &= ~FS_IMMUTABLE_FL;
 	rc = ioctl(fd, FS_IOC_SETFLAGS, &flag);
-	if (rc == -1)
+	if (rc == -1) {
+		pb_log_fn("FS_IOC_SETFLAGS failed: (%d) %s\n", errno,
+			strerror(errno));
 		goto exit;
+	}
 
+delete:
 	close(fd);
 	fd = 0;
 	rc = unlink(path);
+	if (rc == -1) {
+		pb_log_fn("unlink failed: (%d) %s\n", errno, strerror(errno));
+		goto exit;
+	}
 exit:
 	talloc_free(path);
 	close(fd);