diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2019-05-29 13:19:24 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2019-05-29 13:19:24 +0200 |
commit | bedf249e829f34d51cc8c4e4eef864b9b6163450 (patch) | |
tree | d470cbae49955bab404a8ea32ede538015d0bb12 | |
parent | eea062f170e92ae36d498cdc1f6dd010a135978d (diff) | |
download | mkinitfs-bedf249e829f34d51cc8c4e4eef864b9b6163450.tar.bz2 mkinitfs-bedf249e829f34d51cc8c4e4eef864b9b6163450.tar.xz |
nlplug-findfs: fix when cryptheader is a regular file
Handle case when the crypt header is a normal file which is included in
initramfs and not a blockdevice.
-rw-r--r-- | nlplug-findfs.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nlplug-findfs.c b/nlplug-findfs.c index 0283161..9f15de5 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -1213,6 +1213,13 @@ static void usage(int rc) exit(rc); } +static int regular_file(const char *path) +{ + struct stat st; + int r = stat(path, &st); + return r == -1 ? 0 : S_ISREG(st.st_mode); +} + int main(int argc, char *argv[]) { struct pollfd fds[3]; @@ -1262,6 +1269,12 @@ int main(int argc, char *argv[]) break; case 'H': conf.crypt.header.device = EARGF(usage(1)); + /* the header may be in a regular file and not a device */ + if (regular_file(conf.crypt.header.device)) { + snprintf(conf.crypt.header.devnode, + sizeof(conf.crypt.header.devnode), + "%s", conf.crypt.header.device); + } break; case 'h': usage(0); |