From: pratikshinde320@gmail.com (Pratik Shinde)
Subject: [PATCH] erofs-utils: Fail the image creation when source path is not a directory file.
Date: Fri, 16 Aug 2019 14:26:20 +0530 [thread overview]
Message-ID: <20190816085620.22266-1-pratikshinde320@gmail.com> (raw)
In the erofs.mkfs utility, if the source path is not a directory,image
creation should not proceed.since root of the filesystem needs to be a directory.
moving the check to main function.
Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
---
mkfs/main.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/mkfs/main.c b/mkfs/main.c
index 93cacca..8fbfced 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <limits.h>
#include <libgen.h>
+#include <sys/stat.h>
#include "erofs/config.h"
#include "erofs/print.h"
#include "erofs/cache.h"
@@ -187,6 +188,7 @@ int main(int argc, char **argv)
struct erofs_buffer_head *sb_bh;
struct erofs_inode *root_inode;
erofs_nid_t root_nid;
+ struct stat64 st;
erofs_init_configure();
fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
@@ -197,6 +199,15 @@ int main(int argc, char **argv)
usage();
return 1;
}
+ err = lstat64(cfg.c_src_path, &st);
+ if (err)
+ return 1;
+ if ((st.st_mode & S_IFMT) != S_IFDIR) {
+ erofs_err("root of the filesystem is not a directory - %s",
+ cfg.c_src_path);
+ usage();
+ return 1;
+ }
err = dev_open(cfg.c_img_path);
if (err) {
--
2.9.3
next reply other threads:[~2019-08-16 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 8:56 Pratik Shinde [this message]
2019-08-16 12:32 ` [PATCH] erofs-utils: Fail the image creation when source path is not a directory file Gao Xiang
2019-08-16 15:36 ` Li Guifu
2019-08-16 20:43 ` Gao Xiang
-- strict thread matches above, loose matches on Subject: below --
2019-08-16 7:08 [PATCH] erofs-utils : " Pratik Shinde
2019-08-16 7:37 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190816085620.22266-1-pratikshinde320@gmail.com \
--to=pratikshinde320@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.