FreeBSD Bugzilla – Attachment 228584 Details for
Bug 259071
Read past EoF in NFS client and fusefs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Simple file ops program
simple.c (text/plain), 1.58 KB, created by
Agata
on 2021-10-11 12:44:27 UTC
(
hide
)
Description:
Simple file ops program
Filename:
MIME Type:
Creator:
Agata
Created:
2021-10-11 12:44:27 UTC
Size:
1.58 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <fcntl.h> >#include <sys/stat.h> >#include <sys/types.h> >#include <signal.h> > >// if you remove this define then program will work fine. >#define DO_STAT_ON_CHILD 1 > >void child(void) { > struct stat st; > while (1) { > usleep(100000); >#ifdef DO_STAT_ON_CHILD > if (stat("test.bin",&st)<0) { > perror("stat"); > } >#endif > printf("."); > fflush(stdout); > } >} > >int parent(void) { > char buff[0x40000]; > long size,r,exp; > long csize; > int fd; > struct stat st; > > fd = open("test.bin",O_RDWR|O_TRUNC|O_CREAT,0666); > if (fd<0) { > perror("open"); > return 1; > } > csize = 0; > while (1) { > size = random()&0x3FFFF; > switch (random()%3) { > case 0: > if (ftruncate(fd,size)<0) { > perror("ftruncate"); > return 1; > } > csize = size; > break; > case 1: > lseek(fd,0,SEEK_SET); > r = write(fd,buff,size); > if (r<0) { > perror("write"); > return 1; > } > exp = size; > if (r!=exp) { > fprintf(stderr,"write returned wrong number of bytes (returned: %ld, expected: %ld)\n",r,exp); > return 2; > } > if (size>csize) { > csize = size; > } > break; > case 2: > lseek(fd,0,SEEK_SET); > r = read(fd,buff,size); > if (r<0) { > perror("read"); > return 1; > } > exp = (size<csize)?size:csize; > if (r!=exp) { > fprintf(stderr,"read returned wrong number of bytes (returned: %ld, expected: %ld)\n",r,exp); > return 2; > } > break; > } > } > return 0; >} > >int main(void) { > int chpid; > int res; > > if ((chpid=fork())==0) { > child(); > return 0; > } > res = parent(); > kill(chpid,SIGTERM); > return res; >}
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 259071
: 228584 |
228935
|
228973
|
229053