From patchwork Tue Dec 24 08:47:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Yang X-Patchwork-Id: 304910 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D61BA2C00B0 for ; Tue, 24 Dec 2013 19:47:35 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751637Ab3LXIre (ORCPT ); Tue, 24 Dec 2013 03:47:34 -0500 Received: from mail1.windriver.com ([147.11.146.13]:51125 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577Ab3LXIre (ORCPT ); Tue, 24 Dec 2013 03:47:34 -0500 Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail1.windriver.com (8.14.5/8.14.5) with ESMTP id rBO8lWh2001979 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 24 Dec 2013 00:47:32 -0800 (PST) Received: from pek-hostel-vm02.wrs.com (128.224.153.172) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.2.347.0; Tue, 24 Dec 2013 00:47:31 -0800 From: Robert Yang To: , CC: 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 Message-ID: <1387874847-4922-2-git-send-email-liezhi.yang@windriver.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387874847-4922-1-git-send-email-liezhi.yang@windriver.com> References: <1387874847-4922-1-git-send-email-liezhi.yang@windriver.com> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Reviewed-by: Darren Hart --- 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 +#include +#include +#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);