diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2014-03-07 01:59:24 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-07 14:45:22 +0000 |
commit | c93421a39845ca97fd2379fed10c0e82a7fdcb1a (patch) | |
tree | c0742bddfd44c7c896db03edd4e1de3d97bb97eb | |
parent | d8409f8f710c1f36d50ae8ef1cabc76bbdd0600c (diff) | |
download | poky-c93421a39845ca97fd2379fed10c0e82a7fdcb1a.tar.gz |
e2fsprogs: mke2fs: create special file
The do_mknod_internal() is used for creating special file which is
block, character and fifo, most of the code are from debugfs/debugfs.c,
the debugfs/debugfs.c will be modified to use this function.
[YOCTO #4083]
(From OE-Core rev: dcb86f12691b346262c0aadbe5b2f3671b4ecd22)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch new file mode 100644 index 0000000000..3847b6e5ce --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch | |||
@@ -0,0 +1,103 @@ | |||
1 | From ae7d33823bfc330e08b25c5fe4d25838ef7c77ce Mon Sep 17 00:00:00 2001 | ||
2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
3 | Date: Mon, 23 Dec 2013 03:13:28 -0500 | ||
4 | Subject: [PATCH 03/11] misc/create_inode.c: create special file | ||
5 | |||
6 | The do_mknod_internal() is used for creating special file which is | ||
7 | block, character and fifo, most of the code are from debugfs/debugfs.c, | ||
8 | the debugfs/debugfs.c will be modified to use this function. | ||
9 | |||
10 | Upstream-Status: Backport | ||
11 | |||
12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
13 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
14 | --- | ||
15 | misc/create_inode.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
16 | 1 file changed, 72 insertions(+) | ||
17 | |||
18 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
19 | index b68b910..4da8aff 100644 | ||
20 | --- a/misc/create_inode.c | ||
21 | +++ b/misc/create_inode.c | ||
22 | @@ -11,6 +11,78 @@ | ||
23 | /* Make a special file which is block, character and fifo */ | ||
24 | errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) | ||
25 | { | ||
26 | + ext2_ino_t ino; | ||
27 | + errcode_t retval; | ||
28 | + struct ext2_inode inode; | ||
29 | + unsigned long major, minor, mode; | ||
30 | + int filetype; | ||
31 | + | ||
32 | + switch(st->st_mode & S_IFMT) { | ||
33 | + case S_IFCHR: | ||
34 | + mode = LINUX_S_IFCHR; | ||
35 | + filetype = EXT2_FT_CHRDEV; | ||
36 | + break; | ||
37 | + case S_IFBLK: | ||
38 | + mode = LINUX_S_IFBLK; | ||
39 | + filetype = EXT2_FT_BLKDEV; | ||
40 | + break; | ||
41 | + case S_IFIFO: | ||
42 | + mode = LINUX_S_IFIFO; | ||
43 | + filetype = EXT2_FT_FIFO; | ||
44 | + break; | ||
45 | + } | ||
46 | + | ||
47 | + if (!(current_fs->flags & EXT2_FLAG_RW)) { | ||
48 | + com_err(__func__, 0, "Filesystem opened read/only"); | ||
49 | + return -1; | ||
50 | + } | ||
51 | + retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &ino); | ||
52 | + if (retval) { | ||
53 | + com_err(__func__, retval, 0); | ||
54 | + return retval; | ||
55 | + } | ||
56 | + | ||
57 | +#ifdef DEBUGFS | ||
58 | + printf("Allocated inode: %u\n", ino); | ||
59 | +#endif | ||
60 | + retval = ext2fs_link(current_fs, cwd, name, ino, filetype); | ||
61 | + if (retval == EXT2_ET_DIR_NO_SPACE) { | ||
62 | + retval = ext2fs_expand_dir(current_fs, cwd); | ||
63 | + if (retval) { | ||
64 | + com_err(__func__, retval, "while expanding directory"); | ||
65 | + return retval; | ||
66 | + } | ||
67 | + retval = ext2fs_link(current_fs, cwd, name, ino, filetype); | ||
68 | + } | ||
69 | + if (retval) { | ||
70 | + com_err(name, retval, 0); | ||
71 | + return -1; | ||
72 | + } | ||
73 | + if (ext2fs_test_inode_bitmap2(current_fs->inode_map, ino)) | ||
74 | + com_err(__func__, 0, "Warning: inode already set"); | ||
75 | + ext2fs_inode_alloc_stats2(current_fs, ino, +1, 0); | ||
76 | + memset(&inode, 0, sizeof(inode)); | ||
77 | + inode.i_mode = mode; | ||
78 | + inode.i_atime = inode.i_ctime = inode.i_mtime = | ||
79 | + current_fs->now ? current_fs->now : time(0); | ||
80 | + | ||
81 | + major = major(st->st_rdev); | ||
82 | + minor = minor(st->st_rdev); | ||
83 | + | ||
84 | + if ((major < 256) && (minor < 256)) { | ||
85 | + inode.i_block[0] = major * 256 + minor; | ||
86 | + inode.i_block[1] = 0; | ||
87 | + } else { | ||
88 | + inode.i_block[0] = 0; | ||
89 | + inode.i_block[1] = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12); | ||
90 | + } | ||
91 | + inode.i_links_count = 1; | ||
92 | + | ||
93 | + retval = ext2fs_write_new_inode(current_fs, ino, &inode); | ||
94 | + if (retval) | ||
95 | + com_err(__func__, retval, "while creating inode %u", ino); | ||
96 | + | ||
97 | + return retval; | ||
98 | } | ||
99 | |||
100 | /* Make a symlink name -> target */ | ||
101 | -- | ||
102 | 1.7.10.4 | ||
103 | |||