]> granicus.if.org Git - strace/blobdiff - file_ioctl.c
Remove HAVE_STRUCT_TCB_EXT_ARG, ext_arg, and u_lrval
[strace] / file_ioctl.c
index 0f7824e49c05d04a415c9a009cfae45280651fda..fec2f69b0bbd447125b3d8882e44976005e0c935 100644 (file)
@@ -80,11 +80,20 @@ print_file_dedupe_range_info(struct tcb *tcp, void *elem_buf,
                             size_t elem_size, void *data)
 {
        const struct file_dedupe_range_info *info = elem_buf;
+       unsigned int *count = data;
+
+       if (count) {
+               if (*count == 0) {
+                       tprints("...");
+                       return false;
+               }
+               --*count;
+       }
 
        if (entering(tcp)) {
-               tprintf("{dest_fd=%" PRIi64
-                       ", dest_offset=%" PRIu64 "}",
-                       (int64_t) info->dest_fd,
+               tprints("{dest_fd=");
+               printfd(tcp, info->dest_fd);
+               tprintf(", dest_offset=%" PRIu64 "}",
                        (uint64_t) info->dest_offset);
        } else {
                tprintf("{bytes_deduped=%" PRIu64 ", status=%d}",
@@ -114,7 +123,8 @@ print_fiemap_extent(struct tcb *tcp, void *elem_buf, size_t elem_size, void *dat
 #endif /* HAVE_LINUX_FIEMAP_H */
 
 int
-file_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
+file_ioctl(struct tcb *const tcp, const unsigned int code,
+          const kernel_ulong_t arg)
 {
        switch (code) {
        case FICLONE:   /* W */
@@ -128,11 +138,11 @@ file_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
                if (umove_or_printaddr(tcp, arg, &args))
                        break;
 
-               tprintf("{src_fd=%" PRIi64
-                       ", src_offset=%" PRIu64
+               tprints("{src_fd=");
+               printfd(tcp, args.src_fd);
+               tprintf(", src_offset=%" PRIu64
                        ", src_length=%" PRIu64
                        ", dest_offset=%" PRIu64 "}",
-                       (int64_t) args.src_fd,
                        (uint64_t) args.src_offset,
                        (uint64_t) args.src_length,
                        (uint64_t) args.dest_offset);
@@ -141,6 +151,10 @@ file_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
 
        case FIDEDUPERANGE: { /* RW */
                struct file_dedupe_range args;
+               struct file_dedupe_range_info info;
+               unsigned int *limit = NULL;
+               unsigned int count = 2;
+               bool rc;
 
                if (entering(tcp))
                        tprints(", ");
@@ -162,19 +176,16 @@ file_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
                                (uint16_t) args.dest_count);
                }
 
-               bool rc = false;
                tprints("info=");
-               if (abbrev(tcp)) {
-                       tprints("...");
-               } else {
-                       struct file_dedupe_range_info info;
-                       rc = print_array(tcp,
-                                        arg + offsetof(typeof(args), info),
-                                        args.dest_count,
-                                        &info, sizeof(info),
-                                        umoven_or_printaddr,
-                                        print_file_dedupe_range_info, 0);
-               }
+
+               /* Limit how many elements we print in abbrev mode. */
+               if (abbrev(tcp) && args.dest_count > count)
+                       limit = &count;
+
+               rc = print_array(tcp, arg + offsetof(typeof(args), info),
+                                args.dest_count, &info, sizeof(info),
+                                umoven_or_printaddr,
+                                print_file_dedupe_range_info, limit);
 
                tprints("}");
                if (!rc || exiting(tcp))