Support comments in fs config
[project/make_ext4fs.git] / make_ext4fs.c
index fa04263..bc63236 100644 (file)
 #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
-   Special files: sockets, devices, fifos
  */
 
 static int filter_dot(const struct dirent *d)
@@ -154,19 +147,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)) {
@@ -235,6 +225,11 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
                        free(subdir_dir_path);
                } else if (dentries[i].file_type == EXT4_FT_SYMLINK) {
                        entry_inode = make_link(dentries[i].link);
+               } else if (dentries[i].file_type == EXT4_FT_CHRDEV ||
+                          dentries[i].file_type == EXT4_FT_BLKDEV ||
+                          dentries[i].file_type == EXT4_FT_SOCK ||
+                          dentries[i].file_type == EXT4_FT_FIFO) {
+                       entry_inode = make_special(dentries[i].full_path);
                } else {
                        error("unknown file type on %s", dentries[i].path);
                        entry_inode = 0;
@@ -360,7 +355,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;