FreeBSD Bugzilla – Attachment 121746 Details for
Bug 164793
[kern] RLIMIT_FSIZE does not work, affecting ftruncate(2) and truncate(2)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.txt
file.txt (text/plain), 1000 bytes, created by
Nicolas Bourdaud
on 2012-02-05 11:50:08 UTC
(
hide
)
Description:
file.txt
Filename:
MIME Type:
Creator:
Nicolas Bourdaud
Created:
2012-02-05 11:50:08 UTC
Size:
1000 bytes
patch
obsolete
>#include <unistd.h> >#include <sys/time.h> >#include <sys/resource.h> >#include <stdio.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> >#include <signal.h> >#include <errno.h> >#include <string.h> > >#define TARGETSIZE 80000 >#define LIMSIZE 60000 >#define PATTSIZE 27 > > >int main(void) >{ > struct rlimit lim; > int fd; > ssize_t retc; > size_t count = 0; > const char pattern[PATTSIZE] = "Hello world!"; > > signal(SIGXFSZ, SIG_IGN); > lim.rlim_cur = LIMSIZE; > setrlimit(RLIMIT_FSIZE, &lim); > > fd = open("result.txt", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); > > while (count < TARGETSIZE) { > retc = write(fd, pattern, PATTSIZE); > > if (retc < PATTSIZE && retc > 0) > fprintf(stderr, > "added %zi bytes instead of %u bytes after %zu bytes\n", > retc, PATTSIZE, count); > else if (retc < 0) { > fprintf(stderr, > "failed when adding %u bytes after %zu bytes (error: %s)\n", > PATTSIZE, count, strerror(errno)); > break; > } > count += retc; > } > > 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 164793
: 121746