btrfs-progs: receive: implement the update_extent callback
[platform/upstream/btrfs-progs.git] / send-test.c
index cb1f57d..af8229e 100644 (file)
@@ -21,8 +21,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
-
 #include <unistd.h>
 #include <stdint.h>
 #include <dirent.h>
@@ -72,7 +70,7 @@ static int print_subvol(const char *path, const u8 *uuid, u64 ctransid,
                        void *user)
 {
        struct recv_args *r = user;
-       char uuid_str[128];
+       char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
 
        r->full_subvol_path = path_cat(r->root_path, path);
        uuid_unparse(uuid, uuid_str);
@@ -88,8 +86,8 @@ static int print_snapshot(const char *path, const u8 *uuid, u64 ctransid,
                          void *user)
 {
        struct recv_args *r = user;
-       char uuid_str[128];
-       char parent_uuid_str[128];
+       char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
+       char parent_uuid_str[BTRFS_UUID_UNPARSED_SIZE];
 
        r->full_subvol_path = path_cat(r->root_path, path);
        uuid_unparse(uuid, uuid_str);
@@ -354,7 +352,7 @@ static void *process_thread(void *arg_)
        int ret;
 
        while (1) {
-               ret = btrfs_read_and_process_send_stream(pipefd[-1],
+               ret = btrfs_read_and_process_send_stream(pipefd[0],
                                                         &send_ops_print, arg_, 0);
                if (ret)
                        break;
@@ -371,7 +369,6 @@ int main(int argc, char **argv)
        int ret = 0;
        int subvol_fd;
        pthread_t t_read;
-       pthread_attr_t t_attr;
        void *t_err = NULL;
        struct recv_args r;
 
@@ -401,13 +398,6 @@ int main(int argc, char **argv)
                goto out;
        }
 
-       ret = pthread_attr_init(&t_attr);
-       if (ret < 0) {
-               fprintf(stderr, "ERROR: pthread init failed. %s\n",
-                       strerror(ret));
-               goto out;
-       }
-
        ret = pipe(pipefd);
        if (ret < 0) {
                ret = errno;
@@ -415,7 +405,7 @@ int main(int argc, char **argv)
                goto out;
        }
 
-       ret = pthread_create(&t_read, &t_attr, process_thread, &r);
+       ret = pthread_create(&t_read, NULL, process_thread, &r);
        if (ret < 0) {
                ret = errno;
                fprintf(stderr, "ERROR: pthread create failed. %s\n",
@@ -452,7 +442,6 @@ int main(int argc, char **argv)
                goto out;
        }
 
-       pthread_attr_destroy(&t_attr);
 out:
-       return ret;
+       return !!ret;
 }