The Samba-Bugzilla – Attachment 12557 Details for
Bug 11588
better handling for --preallocate with --sparse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test program to show that fallocate followed by punch hole works just fine....
test-fallocate.c (text/x-csrc), 999 bytes, created by
Theodore Ts'o
on 2016-10-08 23:31:03 UTC
(
hide
)
Description:
Test program to show that fallocate followed by punch hole works just fine....
Filename:
MIME Type:
Creator:
Theodore Ts'o
Created:
2016-10-08 23:31:03 UTC
Size:
999 bytes
patch
obsolete
>#ifndef _LARGEFILE_SOURCE >#define _LARGEFILE_SOURCE >#endif >#ifndef _LARGEFILE64_SOURCE >#define _LARGEFILE64_SOURCE >#endif > >#include <sys/stat.h> >#include <sys/syscall.h> >#include <sys/types.h> >#include <fcntl.h> >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <ctype.h> > >// #include <linux/falloc.h> >#define FALLOC_FL_KEEP_SIZE 0x01 >#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ >#define FALLOC_FL_COLLAPSE_RANGE 0x08 >#define FALLOC_FL_ZERO_RANGE 0x10 > >int main(int argc, char **argv) >{ > int fd; > int error; > > fd = open("test-file", O_WRONLY|O_LARGEFILE|O_CREAT|O_TRUNC, 0700); > if (fd < 0) { > perror("Error opening file"); > exit(EXIT_FAILURE); > } > > error = syscall(SYS_fallocate, fd, 0, 0, 1024 * 1024); > if (error < 0) { > perror("fallocate failed"); > exit(1); > } > > error = syscall(SYS_fallocate, fd, > FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, > 32 * 1024, 32 * 1024); > if (error < 0) { > perror("punch hole failed"); > exit(1); > } > > close(fd); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 11588
:
12556
| 12557