X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmake_ext4fs.git;a=blobdiff_plain;f=make_ext4fs.c;h=5087811026126d4073f16f502d24b1784ebca8c9;hp=3623426d03e6e653a95cad759ba77685e1ca1737;hb=d8400e132c67a993248d25fd9026dcc5ffedc96c;hpb=c657f39e1660dae17422b07fcf9f138bcf85bfbc diff --git a/make_ext4fs.c b/make_ext4fs.c index 3623426..5087811 100644 --- a/make_ext4fs.c +++ b/make_ext4fs.c @@ -35,12 +35,6 @@ #include #include -#ifndef USE_MINGW - -#define O_BINARY 0 - -#endif - /* TODO: Not implemented: Allocating blocks in the same block group as the file inode Hash or binary tree directories @@ -72,7 +66,6 @@ static u32 build_default_directory_structure(const char *dir_path) return root_inode; } -#ifndef USE_MINGW /* Read a local directory and create the same tree in the generated filesystem. Calls itself recursively with each directory in the given directory. full_path is an absolute or relative path, with a trailing slash, to the @@ -153,19 +146,16 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path } uint64_t capabilities; if (fs_config_func != NULL) { -#ifdef ANDROID unsigned int mode = 0; unsigned int uid = 0; unsigned int gid = 0; int dir = S_ISDIR(stat.st_mode); - fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities); - dentries[i].mode = mode; - dentries[i].uid = uid; - dentries[i].gid = gid; - dentries[i].capabilities = capabilities; -#else - error("can't set android permissions - built without android support"); -#endif + if (fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities)) { + dentries[i].mode = mode; + dentries[i].uid = uid; + dentries[i].gid = gid; + dentries[i].capabilities = capabilities; + } } if (S_ISREG(stat.st_mode)) { @@ -251,16 +241,6 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path if (ret) error("failed to set permissions on %s\n", dentries[i].path); - /* - * It's important to call inode_set_selinux() before - * inode_set_capabilities(). Extended attributes need to - * be stored sorted order, and we guarantee this by making - * the calls in the proper order. - * Please see xattr_assert_sane() in contents.c - */ - ret = inode_set_selinux(entry_inode, dentries[i].secon); - if (ret) - error("failed to set SELinux context on %s\n", dentries[i].path); ret = inode_set_capabilities(entry_inode, dentries[i].capabilities); if (ret) error("failed to set capability on %s\n", dentries[i].path); @@ -269,13 +249,11 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path free(dentries[i].full_path); free(dentries[i].link); free((void *)dentries[i].filename); - free(dentries[i].secon); } free(dentries); return inode; } -#endif static u32 compute_block_size() { @@ -364,7 +342,7 @@ int make_ext4fs(const char *filename, long long len, reset_ext4fs_info(); info.len = len; - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { error_errno("open"); return EXIT_FAILURE; @@ -542,17 +520,11 @@ int make_ext4fs_internal(int fd, const char *_directory, if (info.feat_compat & EXT4_FEATURE_COMPAT_RESIZE_INODE) ext4_create_resize_inode(); -#ifdef USE_MINGW - // Windows needs only 'create an empty fs image' functionality - assert(!directory); - root_inode_num = build_default_directory_structure(mountpoint); -#else if (directory) root_inode_num = build_directory_structure(directory, mountpoint, 0, fs_config_func, verbose, fixed_time); else root_inode_num = build_default_directory_structure(mountpoint); -#endif root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; inode_set_permissions(root_inode_num, root_mode, 0, 0, 0);