linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dump.f2fs: support dump_file from image
@ 2014-08-19 22:21 Jaegeuk Kim
  2014-08-19 22:21 ` [PATCH 2/2] fsck.f2fs: show inode numbers Jaegeuk Kim
  2014-08-26 23:36 ` [PATCH 1/2] dump.f2fs: support dump_file from image JP Abgrall
  0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-08-19 22:21 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds supporting dump_file, which can extract a file from image.

You can simply select [yes|no] when doing dump.f2fs -i [inode number] [img].

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/dump.c       | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fsck/mount.c      |   3 +-
 include/f2fs_fs.h |   4 +-
 lib/libf2fs_io.c  |  22 ++++----
 4 files changed, 171 insertions(+), 11 deletions(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 880e78a..fad6c84 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -115,6 +115,158 @@ void ssa_dump(struct f2fs_sb_info *sbi, int start_ssa, int end_ssa)
 	close(fd);
 }
 
+static void dump_data_blk(int fd, __u64 offset, u32 blkaddr)
+{
+	char buf[F2FS_BLKSIZE];
+
+	if (blkaddr == NULL_ADDR)
+		return;
+
+	/* get data */
+	if (blkaddr == NEW_ADDR) {
+		memset(buf, 0, F2FS_BLKSIZE);
+	} else {
+		int ret;
+		ret = dev_read_block(buf, blkaddr);
+		ASSERT(ret >= 0);
+	}
+
+	/* write blkaddr */
+	fd_write(fd, buf, offset, F2FS_BLKSIZE);
+}
+
+static void dump_node_blk(struct f2fs_sb_info *sbi, int fd, int ntype,
+						u32 nid, u64 *ofs)
+{
+	struct node_info ni;
+	struct f2fs_node *node_blk;
+	int i, ret;
+	u32 idx, skip;
+
+	switch (ntype) {
+	case TYPE_DIRECT_NODE:
+		skip = idx = ADDRS_PER_BLOCK;
+		break;
+	case TYPE_INDIRECT_NODE:
+		idx = NIDS_PER_BLOCK;
+		skip = idx * ADDRS_PER_BLOCK;
+		break;
+	case TYPE_DOUBLE_INDIRECT_NODE:
+		skip = 0;
+		idx = NIDS_PER_BLOCK;
+		break;
+	}
+
+	if (nid == 0) {
+		*ofs += skip;
+		return;
+	}
+
+	ret = get_node_info(sbi, nid, &ni);
+	ASSERT(ret >= 0);
+
+	node_blk = calloc(BLOCK_SZ, 1);
+	dev_read_block(node_blk, ni.blk_addr);
+
+	for (i = 0; i < idx; i++, (*ofs)++) {
+		switch (ntype) {
+		case TYPE_DIRECT_NODE:
+			dump_data_blk(fd, *ofs * F2FS_BLKSIZE,
+					le32_to_cpu(node_blk->dn.addr[i]));
+			break;
+		case TYPE_INDIRECT_NODE:
+			dump_node_blk(sbi, fd, TYPE_DIRECT_NODE,
+					le32_to_cpu(node_blk->in.nid[i]), ofs);
+			break;
+		case TYPE_DOUBLE_INDIRECT_NODE:
+			dump_node_blk(sbi, fd, TYPE_INDIRECT_NODE,
+					le32_to_cpu(node_blk->in.nid[i]), ofs);
+			break;
+		}
+	}
+	free(node_blk);
+}
+
+static void dump_inode_blk(struct f2fs_sb_info *sbi, int fd, u32 nid,
+					struct f2fs_node *node_blk)
+{
+	u32 i = 0;
+	u64 ofs = 0;
+
+	/* TODO: need to dump xattr */
+
+	if((node_blk->i.i_inline & F2FS_INLINE_DATA)){
+		DBG(3, "ino[0x%x] has inline data!\n", nid);
+		/* recover from inline data */
+		fd_write(fd, ((unsigned char *)node_blk) + INLINE_DATA_OFFSET,
+							0, MAX_INLINE_DATA);
+		return;
+	}
+
+	/* check data blocks in inode */
+	for (i = 0; i < ADDRS_PER_INODE(&node_blk->i); i++, ofs++)
+		dump_data_blk(fd, ofs * F2FS_BLKSIZE,
+				le32_to_cpu(node_blk->i.i_addr[i]));
+
+	/* check node blocks in inode */
+	for (i = 0; i < 5; i++) {
+		if (i == 0 || i == 1)
+			dump_node_blk(sbi, fd, TYPE_DIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else if (i == 2 || i == 3)
+			dump_node_blk(sbi, fd, TYPE_INDIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else if (i == 4)
+			dump_node_blk(sbi, fd, TYPE_DOUBLE_INDIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else
+			ASSERT(0);
+	}
+}
+
+void dump_file(struct f2fs_sb_info *sbi, struct node_info *ni,
+					struct f2fs_node *node_blk)
+{
+	struct f2fs_inode *inode = &node_blk->i;
+	u32 imode = le32_to_cpu(inode->i_mode);
+	char name[255] = {0};
+	char path[1024] = {0};
+	char ans[255] = {0};
+	int fd, ret;
+
+	if (!S_ISREG(imode)) {
+		MSG(0, "Not a regular file\n\n");
+		return;
+	}
+
+	printf("Do you want to dump this file into ./lost_found/? [Y/N] ");
+	ret = scanf("%s", ans);
+	ASSERT(ret >= 0);
+
+	if (!strcasecmp(ans, "y")) {
+		ret = system("mkdir -p ./lost_found");
+		ASSERT(ret >= 0);
+
+		/* make a file */
+		strncpy(name, (const char *)inode->i_name,
+					le32_to_cpu(inode->i_namelen));
+		name[le32_to_cpu(inode->i_namelen)] = 0;
+		sprintf(path, "./lost_found/%s", name);
+
+		fd = open(path, O_TRUNC|O_CREAT|O_RDWR, 0666);
+		ASSERT(fd >= 0);
+
+		/* dump file's data */
+		dump_inode_blk(sbi, fd, ni->ino, node_blk);
+
+		/* adjust file size */
+		ret = ftruncate(fd, le32_to_cpu(inode->i_size));
+		ASSERT(ret >= 0);
+
+		close(fd);
+	}
+}
+
 int dump_node(struct f2fs_sb_info *sbi, nid_t nid)
 {
 	struct node_info ni;
@@ -142,6 +294,7 @@ int dump_node(struct f2fs_sb_info *sbi, nid_t nid)
 	if (le32_to_cpu(node_blk->footer.ino) == ni.ino &&
 			le32_to_cpu(node_blk->footer.nid) == ni.nid) {
 		print_node_info(node_blk);
+		dump_file(sbi, &ni, node_blk);
 	} else {
 		MSG(0, "Invalid node block\n\n");
 	}
diff --git a/fsck/mount.c b/fsck/mount.c
index 7ea3296..7bb7504 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -223,7 +223,8 @@ int validate_super_block(struct f2fs_sb_info *sbi, int block)
 	u64 offset = (block + 1) * F2FS_SUPER_OFFSET;
 	sbi->raw_super = malloc(sizeof(struct f2fs_super_block));
 
-	if (dev_read(sbi->raw_super, offset, sizeof(struct f2fs_super_block)))
+	if (dev_read(sbi->raw_super, offset,
+			sizeof(struct f2fs_super_block), config.fd))
 		return -1;
 
 	if (!sanity_check_raw_super(sbi->raw_super))
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 80ce918..0b9d242 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -173,6 +173,7 @@ struct f2fs_configuration {
 	char *vol_label;
 	int heap;
 	int32_t fd;
+	int32_t dump_fd;
 	char *device_name;
 	char *extension_list;
 	int dbg_lv;
@@ -669,11 +670,12 @@ extern int f2fs_dev_is_umounted(struct f2fs_configuration *);
 extern int f2fs_get_device_info(struct f2fs_configuration *);
 extern void f2fs_finalize_device(struct f2fs_configuration *);
 
-extern int dev_read(void *, __u64, size_t);
+extern int dev_read(void *, __u64, size_t, int);
 extern int dev_write(void *, __u64, size_t);
 /* All bytes in the buffer must be 0 use dev_fill(). */
 extern int dev_fill(void *, __u64, size_t);
 
+extern int fd_write(int, void *, __u64, size_t);
 extern int dev_read_block(void *, __u64);
 extern int dev_read_blocks(void *, __u64, __u32 );
 
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 5d9b68d..46b5484 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -28,11 +28,11 @@ struct f2fs_configuration config;
 /*
  * IO interfaces
  */
-int dev_read(void *buf, __u64 offset, size_t len)
+int dev_read(void *buf, __u64 offset, size_t len, int fd)
 {
-	if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
+	if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0)
 		return -1;
-	if (read(config.fd, buf, len) < 0)
+	if (read(fd, buf, len) < 0)
 		return -1;
 	return 0;
 }
@@ -46,6 +46,15 @@ int dev_write(void *buf, __u64 offset, size_t len)
 	return 0;
 }
 
+int fd_write(int fd, void *buf, __u64 offset, size_t len)
+{
+	if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0)
+		return -1;
+	if (write(fd, buf, len) < 0)
+		return -1;
+	return 0;
+}
+
 int dev_fill(void *buf, __u64 offset, size_t len)
 {
 	/* Only allow fill to zero */
@@ -60,12 +69,7 @@ int dev_fill(void *buf, __u64 offset, size_t len)
 
 int dev_read_block(void *buf, __u64 blk_addr)
 {
-	return dev_read(buf, blk_addr * F2FS_BLKSIZE, F2FS_BLKSIZE);
-}
-
-int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)
-{
-	return dev_read(buf, addr * F2FS_BLKSIZE, nr_blks * F2FS_BLKSIZE);
+	return dev_read(buf, blk_addr * F2FS_BLKSIZE, F2FS_BLKSIZE, config.fd);
 }
 
 void f2fs_finalize_device(struct f2fs_configuration *c)
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] fsck.f2fs: show inode numbers
  2014-08-19 22:21 [PATCH 1/2] dump.f2fs: support dump_file from image Jaegeuk Kim
@ 2014-08-19 22:21 ` Jaegeuk Kim
  2014-08-26 23:36 ` [PATCH 1/2] dump.f2fs: support dump_file from image JP Abgrall
  1 sibling, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-08-19 22:21 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

fsck.f2fs -d 1 [dev]
 : shows inode informations
fsck.f2fs -d -1 [dev]
 : shows directory tree with inode number

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 0f48918..2d8dffb 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -506,7 +506,8 @@ static void print_dentry(__u32 depth, __u8 *name,
 
 	for (i = 1; i < depth; i++)
 		printf("%c   ", tree_mark[i]);
-	printf("%c-- %s\n", last_de ? '`' : '|', name);
+	printf("%c-- %s 0x%x\n", last_de ? '`' : '|',
+				name, le32_to_cpu(de_blk->dentry[idx].ino));
 }
 
 int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
@@ -561,7 +562,7 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
 			}
 		}
 
-		DBG(2, "[%3u] - no[0x%x] name[%s] len[0x%x] ino[0x%x] type[0x%x]\n",
+		DBG(1, "[%3u] - no[0x%x] name[%s] len[0x%x] ino[0x%x] type[0x%x]\n",
 				fsck->dentry_depth, i, name, name_len,
 				le32_to_cpu(de_blk->dentry[i].ino),
 				de_blk->dentry[i].file_type);
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dump.f2fs: support dump_file from image
  2014-08-19 22:21 [PATCH 1/2] dump.f2fs: support dump_file from image Jaegeuk Kim
  2014-08-19 22:21 ` [PATCH 2/2] fsck.f2fs: show inode numbers Jaegeuk Kim
@ 2014-08-26 23:36 ` JP Abgrall
  2014-08-27  0:36   ` Jaegeuk Kim
  1 sibling, 1 reply; 4+ messages in thread
From: JP Abgrall @ 2014-08-26 23:36 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

> diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
> index 5d9b68d..46b5484 100644
> --- a/lib/libf2fs_io.c
> +++ b/lib/libf2fs_io.c
> @@ -28,11 +28,11 @@ struct f2fs_configuration config;
>  /*
>   * IO interfaces
>   */
> -int dev_read(void *buf, __u64 offset, size_t len)
> +int dev_read(void *buf, __u64 offset, size_t len, int fd)

Don't add fd.
This makes the wrong assumption that an FD is actually the underlying
mechanism to read from the device. These IO routines are to be called
without that assumption.
Forcing it in the API here breaks the capability to read/write on
devices that are not files.
If you need to dev_read(), then setup the config appropriately.

For the rationale, see commits
  437dbf67730d2765c4dfc8539b07258e1ca3966f
 15ea79b3ae7f0474ade43ba8b6eb328806e01e15
--

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dump.f2fs: support dump_file from image
  2014-08-26 23:36 ` [PATCH 1/2] dump.f2fs: support dump_file from image JP Abgrall
@ 2014-08-27  0:36   ` Jaegeuk Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-08-27  0:36 UTC (permalink / raw)
  To: JP Abgrall; +Cc: linux-f2fs-devel

On Tue, Aug 26, 2014 at 04:36:58PM -0700, JP Abgrall wrote:
> > diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
> > index 5d9b68d..46b5484 100644
> > --- a/lib/libf2fs_io.c
> > +++ b/lib/libf2fs_io.c
> > @@ -28,11 +28,11 @@ struct f2fs_configuration config;
> >  /*
> >   * IO interfaces
> >   */
> > -int dev_read(void *buf, __u64 offset, size_t len)
> > +int dev_read(void *buf, __u64 offset, size_t len, int fd)
> 
> Don't add fd.
> This makes the wrong assumption that an FD is actually the underlying
> mechanism to read from the device. These IO routines are to be called
> without that assumption.
> Forcing it in the API here breaks the capability to read/write on
> devices that are not files.
> If you need to dev_read(), then setup the config appropriately.

Uhu, it is really ugly codes.
I'll rewrite this as your suggestion.

Change log from v1:
 o refactor codes without fd hacks.

This patch adds supporting dump_file, which can extract a file from image.

You can simply select [yes|no] when doing dump.f2fs -i [inode number] [img].

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/dump.c       | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/f2fs_fs.h |   2 +
 lib/libf2fs_io.c  |   9 ++++
 3 files changed, 164 insertions(+)

diff --git a/fsck/dump.c b/fsck/dump.c
index 880e78a..44d4105 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -115,6 +115,158 @@ void ssa_dump(struct f2fs_sb_info *sbi, int start_ssa, int end_ssa)
 	close(fd);
 }
 
+static void dump_data_blk(__u64 offset, u32 blkaddr)
+{
+	char buf[F2FS_BLKSIZE];
+
+	if (blkaddr == NULL_ADDR)
+		return;
+
+	/* get data */
+	if (blkaddr == NEW_ADDR) {
+		memset(buf, 0, F2FS_BLKSIZE);
+	} else {
+		int ret;
+		ret = dev_read_block(buf, blkaddr);
+		ASSERT(ret >= 0);
+	}
+
+	/* write blkaddr */
+	dev_write_dump(buf, offset, F2FS_BLKSIZE);
+}
+
+static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype,
+						u32 nid, u64 *ofs)
+{
+	struct node_info ni;
+	struct f2fs_node *node_blk;
+	int i, ret;
+	u32 idx, skip;
+
+	switch (ntype) {
+	case TYPE_DIRECT_NODE:
+		skip = idx = ADDRS_PER_BLOCK;
+		break;
+	case TYPE_INDIRECT_NODE:
+		idx = NIDS_PER_BLOCK;
+		skip = idx * ADDRS_PER_BLOCK;
+		break;
+	case TYPE_DOUBLE_INDIRECT_NODE:
+		skip = 0;
+		idx = NIDS_PER_BLOCK;
+		break;
+	}
+
+	if (nid == 0) {
+		*ofs += skip;
+		return;
+	}
+
+	ret = get_node_info(sbi, nid, &ni);
+	ASSERT(ret >= 0);
+
+	node_blk = calloc(BLOCK_SZ, 1);
+	dev_read_block(node_blk, ni.blk_addr);
+
+	for (i = 0; i < idx; i++, (*ofs)++) {
+		switch (ntype) {
+		case TYPE_DIRECT_NODE:
+			dump_data_blk(*ofs * F2FS_BLKSIZE,
+					le32_to_cpu(node_blk->dn.addr[i]));
+			break;
+		case TYPE_INDIRECT_NODE:
+			dump_node_blk(sbi, TYPE_DIRECT_NODE,
+					le32_to_cpu(node_blk->in.nid[i]), ofs);
+			break;
+		case TYPE_DOUBLE_INDIRECT_NODE:
+			dump_node_blk(sbi, TYPE_INDIRECT_NODE,
+					le32_to_cpu(node_blk->in.nid[i]), ofs);
+			break;
+		}
+	}
+	free(node_blk);
+}
+
+static void dump_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
+					struct f2fs_node *node_blk)
+{
+	u32 i = 0;
+	u64 ofs = 0;
+
+	/* TODO: need to dump xattr */
+
+	if((node_blk->i.i_inline & F2FS_INLINE_DATA)){
+		DBG(3, "ino[0x%x] has inline data!\n", nid);
+		/* recover from inline data */
+		dev_write_dump(((unsigned char *)node_blk) + INLINE_DATA_OFFSET,
+							0, MAX_INLINE_DATA);
+		return;
+	}
+
+	/* check data blocks in inode */
+	for (i = 0; i < ADDRS_PER_INODE(&node_blk->i); i++, ofs++)
+		dump_data_blk(ofs * F2FS_BLKSIZE,
+				le32_to_cpu(node_blk->i.i_addr[i]));
+
+	/* check node blocks in inode */
+	for (i = 0; i < 5; i++) {
+		if (i == 0 || i == 1)
+			dump_node_blk(sbi, TYPE_DIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else if (i == 2 || i == 3)
+			dump_node_blk(sbi, TYPE_INDIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else if (i == 4)
+			dump_node_blk(sbi, TYPE_DOUBLE_INDIRECT_NODE,
+					node_blk->i.i_nid[i], &ofs);
+		else
+			ASSERT(0);
+	}
+}
+
+void dump_file(struct f2fs_sb_info *sbi, struct node_info *ni,
+					struct f2fs_node *node_blk)
+{
+	struct f2fs_inode *inode = &node_blk->i;
+	u32 imode = le32_to_cpu(inode->i_mode);
+	char name[255] = {0};
+	char path[1024] = {0};
+	char ans[255] = {0};
+	int ret;
+
+	if (!S_ISREG(imode)) {
+		MSG(0, "Not a regular file\n\n");
+		return;
+	}
+
+	printf("Do you want to dump this file into ./lost_found/? [Y/N] ");
+	ret = scanf("%s", ans);
+	ASSERT(ret >= 0);
+
+	if (!strcasecmp(ans, "y")) {
+		ret = system("mkdir -p ./lost_found");
+		ASSERT(ret >= 0);
+
+		/* make a file */
+		strncpy(name, (const char *)inode->i_name,
+					le32_to_cpu(inode->i_namelen));
+		name[le32_to_cpu(inode->i_namelen)] = 0;
+		sprintf(path, "./lost_found/%s", name);
+
+		config.dump_fd = open(path, O_TRUNC|O_CREAT|O_RDWR, 0666);
+		ASSERT(config.dump_fd >= 0);
+
+		/* dump file's data */
+		dump_inode_blk(sbi, ni->ino, node_blk);
+
+		/* adjust file size */
+		ret = ftruncate(config.dump_fd, le32_to_cpu(inode->i_size));
+		ASSERT(ret >= 0);
+
+		close(config.dump_fd);
+	}
+}
+
 int dump_node(struct f2fs_sb_info *sbi, nid_t nid)
 {
 	struct node_info ni;
@@ -142,6 +294,7 @@ int dump_node(struct f2fs_sb_info *sbi, nid_t nid)
 	if (le32_to_cpu(node_blk->footer.ino) == ni.ino &&
 			le32_to_cpu(node_blk->footer.nid) == ni.nid) {
 		print_node_info(node_blk);
+		dump_file(sbi, &ni, node_blk);
 	} else {
 		MSG(0, "Invalid node block\n\n");
 	}
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 80ce918..9ade334 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -173,6 +173,7 @@ struct f2fs_configuration {
 	char *vol_label;
 	int heap;
 	int32_t fd;
+	int32_t dump_fd;
 	char *device_name;
 	char *extension_list;
 	int dbg_lv;
@@ -671,6 +672,7 @@ extern void f2fs_finalize_device(struct f2fs_configuration *);
 
 extern int dev_read(void *, __u64, size_t);
 extern int dev_write(void *, __u64, size_t);
+extern int dev_write_dump(void *, __u64, size_t);
 /* All bytes in the buffer must be 0 use dev_fill(). */
 extern int dev_fill(void *, __u64, size_t);
 
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 5d9b68d..d5ced53 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -46,6 +46,15 @@ int dev_write(void *buf, __u64 offset, size_t len)
 	return 0;
 }
 
+int dev_write_dump(void *buf, __u64 offset, size_t len)
+{
+	if (lseek64(config.dump_fd, (off64_t)offset, SEEK_SET) < 0)
+		return -1;
+	if (write(config.dump_fd, buf, len) < 0)
+		return -1;
+	return 0;
+}
+
 int dev_fill(void *buf, __u64 offset, size_t len)
 {
 	/* Only allow fill to zero */
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-27  0:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-19 22:21 [PATCH 1/2] dump.f2fs: support dump_file from image Jaegeuk Kim
2014-08-19 22:21 ` [PATCH 2/2] fsck.f2fs: show inode numbers Jaegeuk Kim
2014-08-26 23:36 ` [PATCH 1/2] dump.f2fs: support dump_file from image JP Abgrall
2014-08-27  0:36   ` Jaegeuk Kim

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).