#include #include #include #include #include #include #include #include struct truncate_range { __u32 start_block; __u32 length; }; #define EXT4_IOC_TRUNCATE_BLOCK_RANGE _IOW('f', 18, struct truncate_range) int main(int argc, char ** argv) { struct truncate_range tr; int fd; if(argc != 4){ printf("Usage: \n"); return 0; } memset(&tr, 0, sizeof(struct truncate_range)); tr.start_block = atoi(argv[2]); tr.length = atoi(argv[3]); fd = open(argv[1],O_RDWR ,0666); if(fd) { ioctl(fd, EXT4_IOC_TRUNCATE_BLOCK_RANGE, &tr); close(fd); } perror("Return:\n"); return 0; }