btrfs-progs: tests: Add test case with valid orphan inode
[platform/upstream/btrfs-progs.git] / mkfs / main.c
index 9bb1f60..5a717f7 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 /* #include <sys/dir.h> included via androidcompat.h */
 #include <fcntl.h>
+#include <limits.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <uuid/uuid.h>
@@ -72,7 +73,6 @@ static int create_metadata_block_groups(struct btrfs_root *root, int mixed,
         */
        ret = btrfs_make_block_group(trans, fs_info, bytes_used,
                                     BTRFS_BLOCK_GROUP_SYSTEM,
-                                    BTRFS_FIRST_CHUNK_TREE_OBJECTID,
                                     BTRFS_BLOCK_RESERVED_1M_FOR_SUPER,
                                     BTRFS_MKFS_SYSTEM_GROUP_SIZE);
        allocation->system += BTRFS_MKFS_SYSTEM_GROUP_SIZE;
@@ -93,7 +93,6 @@ static int create_metadata_block_groups(struct btrfs_root *root, int mixed,
                ret = btrfs_make_block_group(trans, fs_info, 0,
                                             BTRFS_BLOCK_GROUP_METADATA |
                                             BTRFS_BLOCK_GROUP_DATA,
-                                            BTRFS_FIRST_CHUNK_TREE_OBJECTID,
                                             chunk_start, chunk_size);
                if (ret)
                        return ret;
@@ -110,7 +109,6 @@ static int create_metadata_block_groups(struct btrfs_root *root, int mixed,
                        return ret;
                ret = btrfs_make_block_group(trans, fs_info, 0,
                                             BTRFS_BLOCK_GROUP_METADATA,
-                                            BTRFS_FIRST_CHUNK_TREE_OBJECTID,
                                             chunk_start, chunk_size);
                allocation->metadata += chunk_size;
                if (ret)
@@ -145,7 +143,6 @@ static int create_data_block_groups(struct btrfs_trans_handle *trans,
                        return ret;
                ret = btrfs_make_block_group(trans, fs_info, 0,
                                             BTRFS_BLOCK_GROUP_DATA,
-                                            BTRFS_FIRST_CHUNK_TREE_OBJECTID,
                                             chunk_start, chunk_size);
                allocation->data += chunk_size;
                if (ret)
@@ -254,8 +251,7 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans,
                return ret;
 
        ret = btrfs_make_block_group(trans, fs_info, 0,
-                                    type, BTRFS_FIRST_CHUNK_TREE_OBJECTID,
-                                    chunk_start, chunk_size);
+                                    type, chunk_start, chunk_size);
 
        type &= BTRFS_BLOCK_GROUP_TYPE_MASK;
        if (type == BTRFS_BLOCK_GROUP_DATA) {
@@ -985,12 +981,13 @@ int main(int argc, char **argv)
                fd = open(file, oflags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
                                         S_IROTH);
                if (fd < 0) {
-                       error("unable to open %s: %s", file, strerror(errno));
+                       error("unable to open %s: %m", file);
                        goto error;
                }
+
                ret = fstat(fd, &statbuf);
                if (ret < 0) {
-                       error("unable to stat %s: %s", file, strerror(errno));
+                       error("unable to stat %s: %m", file);
                        ret = -errno;
                        goto error;
                }
@@ -1029,8 +1026,7 @@ int main(int argc, char **argv)
                path = argv[i];
                ret = test_minimum_size(path, min_dev_size);
                if (ret < 0) {
-                       error("failed to check size for %s: %s",
-                               path, strerror(-ret));
+                       error("failed to check size for %s: %m", path);
                        goto error;
                }
                if (ret > 0) {
@@ -1055,7 +1051,7 @@ int main(int argc, char **argv)
         */
        fd = open(file, O_RDWR);
        if (fd < 0) {
-               error("unable to open %s: %s", file, strerror(errno));
+               error("unable to open %s: %m", file);
                goto error;
        }
        ret = btrfs_prepare_device(fd, file, &dev_block_count, block_count,
@@ -1157,7 +1153,7 @@ int main(int argc, char **argv)
                 */
                fd = open(file, O_RDWR);
                if (fd < 0) {
-                       error("unable to open %s: %s", file, strerror(errno));
+                       error("unable to open %s: %m", file);
                        goto error;
                }
                ret = btrfs_device_already_in_root(root, fd,