X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmake_ext4fs.git;a=blobdiff_plain;f=contents.c;h=1cde871e898bdffe65044c180369ab6960bb8b19;hp=3144de93f4de1ae8f84f3ab2df625ed099ac33e6;hb=d8400e132c67a993248d25fd9026dcc5ffedc96c;hpb=fb5c011b4912fb14cfa87a06a5542c06aecc9278 diff --git a/contents.c b/contents.c index 3144de9..1cde871 100644 --- a/contents.c +++ b/contents.c @@ -18,11 +18,7 @@ #include #include -#ifdef HAVE_ANDROID_OS -#include -#else #include -#endif #define XATTR_SELINUX_SUFFIX "selinux" #define XATTR_CAPS_SUFFIX "capability" @@ -34,10 +30,6 @@ #include "extent.h" #include "indirect.h" -#ifdef USE_MINGW -#define S_IFLNK 0 /* used by make_link, not needed under mingw */ -#endif - static struct block_allocation* saved_allocation_head = NULL; struct block_allocation* get_saved_allocation_chain() { @@ -244,6 +236,40 @@ u32 make_link(const char *link) return inode_num; } +/* Creates a special file on disk. Returns the inode number of the new file */ +u32 make_special(const char *path) +{ + struct ext4_inode *inode; + struct stat s; + u32 inode_num; + + if (stat(path, &s)) { + error("failed to stat file\n"); + return EXT4_ALLOCATE_FAILED; + } + + inode_num = allocate_inode(info); + if (inode_num == EXT4_ALLOCATE_FAILED) { + error("failed to allocate inode\n"); + return EXT4_ALLOCATE_FAILED; + } + + inode = get_inode(inode_num); + if (inode == NULL) { + error("failed to get inode %u", inode_num); + return EXT4_ALLOCATE_FAILED; + } + + inode->i_mode = s.st_mode & S_IFMT; + inode->i_links_count = 1; + inode->i_flags |= aux_info.default_i_flags; + + ((u8 *)inode->i_block)[0] = major(s.st_rdev); + ((u8 *)inode->i_block)[1] = minor(s.st_rdev); + + return inode_num; +} + int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime) { struct ext4_inode *inode = get_inode(inode_num); @@ -463,15 +489,6 @@ static int xattr_add(u32 inode_num, int name_index, const char *name, return result; } -int inode_set_selinux(u32 inode_num, const char *secon) -{ - if (!secon) - return 0; - - return xattr_add(inode_num, EXT4_XATTR_INDEX_SECURITY, - XATTR_SELINUX_SUFFIX, secon, strlen(secon) + 1); -} - int inode_set_capabilities(u32 inode_num, uint64_t capabilities) { if (capabilities == 0) return 0;