linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Yang <liezhi.yang@windriver.com>
To: <tytso@mit.edu>, <dvhart@linux.intel.com>
Cc: <linux-ext4@vger.kernel.org>
Subject: [PATCH V2 01/11] mke2fs: add the ability to copy files from a given directory
Date: Tue, 24 Dec 2013 03:47:17 -0500	[thread overview]
Message-ID: <1387874847-4922-2-git-send-email-liezhi.yang@windriver.com> (raw)
In-Reply-To: <1387874847-4922-1-git-send-email-liezhi.yang@windriver.com>

We will add a -d option which will be used for adding the files from a
given directory to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.

* We already have the basic operations in debugfs:
  - Copy regular file
  - Create directory
  - Create symlink
  - Create special file

  We will move these operations into create_inode.h and create_inode.c,
  then let both mke2fs and debugfs use them.

* What we need to do are:
  - Copy the given directory recursively, this will be done by the
    populate_fs()
  - Set the owner, mode and other informations
  - Handle the hard links

TODO:
  - The libext2fs can't create the socket file (S_IFSOCK), do we have a
    plan to support it ?

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
---
 misc/create_inode.c |   26 ++++++++++++++++++++++++++
 misc/create_inode.h |   17 +++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 misc/create_inode.c
 create mode 100644 misc/create_inode.h

diff --git a/misc/create_inode.c b/misc/create_inode.c
new file mode 100644
index 0000000..46aaa60
--- /dev/null
+++ b/misc/create_inode.c
@@ -0,0 +1,26 @@
+#include "create_inode.h"
+
+/* Make a special file which is block, character and fifo */
+errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
+{
+}
+
+/* Make a symlink name -> target */
+errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target)
+{
+}
+
+/* Make a directory in the fs */
+errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st)
+{
+}
+
+/* Copy the native file to the fs */
+errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
+{
+}
+
+/* Copy files from source_dir to fs */
+errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
+{
+}
diff --git a/misc/create_inode.h b/misc/create_inode.h
new file mode 100644
index 0000000..9fc97fa
--- /dev/null
+++ b/misc/create_inode.h
@@ -0,0 +1,17 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "et/com_err.h"
+#include "e2p/e2p.h"
+#include "ext2fs/ext2fs.h"
+#include "nls-enable.h"
+
+ext2_filsys    current_fs;
+ext2_ino_t     root;
+
+/* For populating the filesystem */
+extern errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir);
+extern errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st);
+extern errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target);
+extern errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st);
+extern errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest);
-- 
1.7.10.4


  reply	other threads:[~2013-12-24  8:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-24  8:47 [PATCH V2 00/11] e2fsprogs/mke2fs: add an option: -d root-directory Robert Yang
2013-12-24  8:47 ` Robert Yang [this message]
2013-12-24  8:47 ` [PATCH V2 02/11] misc/create_inode.c: copy files recursively Robert Yang
2013-12-24  8:47 ` [PATCH V2 03/11] misc/create_inode.c: create special file Robert Yang
2013-12-24  8:47 ` [PATCH V2 04/11] misc/create_inode.c: create symlink Robert Yang
2013-12-24  8:47 ` [PATCH V2 05/11] misc/create_inode.c: copy regular file Robert Yang
2013-12-24  8:47 ` [PATCH V2 06/11] misc/create_inode.c: create directory Robert Yang
2013-12-24  8:47 ` [PATCH V2 07/11] misc/create_inode.c: set owner/mode/time for the inode Robert Yang
2013-12-24  8:47 ` [PATCH V2 08/11] mke2fs.c: add an option: -d root-directory Robert Yang
2013-12-24  8:47 ` [PATCH V2 09/11] misc/create_inode.c: handle hardlinks Robert Yang
2013-12-25  3:14   ` Robert Yang
2013-12-25  3:21   ` [PATCH V3 " Robert Yang
2013-12-24  8:47 ` [PATCH V2 10/11] debugfs: use the functions in misc/create_inode.c Robert Yang
2013-12-24  8:47 ` [PATCH V2 11/11] mke2fs.8.in: update the manual for the -d option Robert Yang

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=1387874847-4922-2-git-send-email-liezhi.yang@windriver.com \
    --to=liezhi.yang@windriver.com \
    --cc=dvhart@linux.intel.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).