/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright (c) 2014 by Delphix. All rights reserved.
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <libzfs.h>
#include <umem.h>
#include <stdlib.h>
#include <stddef.h>
extern int errno;
static void
{
}
typedef struct segment {
int seg_type;
} seg_t;
/*
* Return an appropriate whence value, depending on whether the file begins
* with a holes or data.
*/
static int
{
/* ENXIO means no holes were found */
return (SEEK_DATA);
perror("lseek failed");
exit(1);
}
}
static void
{
if (0 == bs)
perror("zfs_get_hole_count");
exit(1);
}
if (options & PRINT_VERBOSE)
} else {
}
}
/* Verify libzfs sees the same number of hole blocks found manually. */
if (lz_holes != hole_blks_seen) {
exit(1);
}
return;
}
if (options & PRINT_DATA)
if (options & PRINT_HOLE)
}
int
{
char *fname;
switch (c) {
case 'd':
options |= PRINT_DATA;
break;
case 'h':
options |= PRINT_HOLE;
break;
case 'v':
options |= PRINT_VERBOSE;
break;
}
}
if (argc != 1)
perror("open failed");
exit(1);
}
perror("fstat failed");
exit(1);
}
seg_t *s;
}
perror("lseek failed");
exit(1);
}
/*
* If this file ends with a hole block, then populate the length of
* the last segment, otherwise this is the end of the file, so
* discard the remaining zero length segment.
*/
} else {
(void) list_remove_tail(&seg_list);
}
return (0);
}