]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
f54969357019c2a37fc0c6b154d054c9538add05
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 2dcf8e92bc39e05b3c799f53fe911c024aee4375 Mon Sep 17 00:00:00 2001
2 From: Robert Yang <liezhi.yang@windriver.com>
3 Date: Fri, 23 Oct 2015 03:21:05 -0700
4 Subject: [PATCH] copy-in: create hardlinks with the correct directory
5 filetype
6
7 When we're creating hard links via ext2fs_link, the (misnamed?) flags
8 argument specifies the filetype for the directory entry. This is
9 *derived* from i_mode, so provide a translator. Otherwise, fsck will
10 complain about unset file types.
11
12 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14
15 Upstream-Status: Backport
16
17 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18 ---
19 misc/create_inode.c | 33 +++++++++++++++++++++++++++++++--
20 1 file changed, 31 insertions(+), 2 deletions(-)
21
22 diff --git a/misc/create_inode.c b/misc/create_inode.c
23 index fcec5aa..b8565da 100644
24 --- a/misc/create_inode.c
25 +++ b/misc/create_inode.c
26 @@ -22,6 +22,33 @@
27 /* For saving the hard links */
28 int hdlink_cnt = HDLINK_CNT;
29
30 +static int ext2_file_type(unsigned int mode)
31 +{
32 + if (LINUX_S_ISREG(mode))
33 + return EXT2_FT_REG_FILE;
34 +
35 + if (LINUX_S_ISDIR(mode))
36 + return EXT2_FT_DIR;
37 +
38 + if (LINUX_S_ISCHR(mode))
39 + return EXT2_FT_CHRDEV;
40 +
41 + if (LINUX_S_ISBLK(mode))
42 + return EXT2_FT_BLKDEV;
43 +
44 + if (LINUX_S_ISLNK(mode))
45 + return EXT2_FT_SYMLINK;
46 +
47 + if (LINUX_S_ISFIFO(mode))
48 + return EXT2_FT_FIFO;
49 +
50 + if (LINUX_S_ISSOCK(mode))
51 + return EXT2_FT_SOCK;
52 +
53 + return 0;
54 +}
55 +
56 +
57 /* Link an inode number to a directory */
58 static errcode_t add_link(ext2_ino_t parent_ino, ext2_ino_t ino, const char *name)
59 {
60 @@ -34,14 +61,16 @@ static errcode_t add_link(ext2_ino_t parent_ino, ext2_ino_t ino, const char *nam
61 return retval;
62 }
63
64 - retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
65 + retval = ext2fs_link(current_fs, parent_ino, name, ino,
66 + ext2_file_type(inode.i_mode));
67 if (retval == EXT2_ET_DIR_NO_SPACE) {
68 retval = ext2fs_expand_dir(current_fs, parent_ino);
69 if (retval) {
70 com_err(__func__, retval, "while expanding directory");
71 return retval;
72 }
73 - retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
74 + retval = ext2fs_link(current_fs, parent_ino, name, ino,
75 + ext2_file_type(inode.i_mode));
76 }
77 if (retval) {
78 com_err(__func__, retval, "while linking %s", name);
79 --
80 1.7.9.5
81