Remove unused functions
[project/make_ext4fs.git] / make_ext4fs.c
index 3623426..553b066 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include "make_ext4fs.h"
 #include "ext4_utils.h"
 #include "allocate.h"
 #include "contents.h"
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#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 +65,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 +145,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 +240,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 +248,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()
 {
@@ -334,48 +311,6 @@ static u32 compute_bg_desc_reserve_blocks()
        return bg_desc_reserve_blocks;
 }
 
-void reset_ext4fs_info() {
-       // Reset all the global data structures used by make_ext4fs so it
-       // can be called again.
-       memset(&info, 0, sizeof(info));
-       memset(&aux_info, 0, sizeof(aux_info));
-
-       if (ext4_sparse_file) {
-               sparse_file_destroy(ext4_sparse_file);
-               ext4_sparse_file = NULL;
-       }
-}
-
-int make_ext4fs_sparse_fd(int fd, long long len,
-                               const char *mountpoint)
-{
-       reset_ext4fs_info();
-       info.len = len;
-
-       return make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 1, 0, 0, 0, -1, NULL);
-}
-
-int make_ext4fs(const char *filename, long long len,
-                               const char *mountpoint)
-{
-       int fd;
-       int status;
-
-       reset_ext4fs_info();
-       info.len = len;
-
-       fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
-       if (fd < 0) {
-               error_errno("open");
-               return EXIT_FAILURE;
-       }
-
-       status = make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 0, 0, 1, 0, -1, NULL);
-       close(fd);
-
-       return status;
-}
-
 /* return a newly-malloc'd string that is a copy of str.  The new string
    is guaranteed to have a trailing slash.  If absolute is true, the new string
    is also guaranteed to have a leading slash.
@@ -542,17 +477,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);