On Tue, Oct 20, 1998 at 06:42:29AM +0200, MOLNAR Ingo wrote:
> system calls have only a single, integer return value. So if it returns
> -EFAULT, then it cannot be short. Yes you can query the file position.
> (this is what i ment by hard, because there are atomicity issues with
> multithreaded apps) it's a messy area :(
A short buffer under 2.1.x causes a short read, it does not return
EFAULT (last time I checked anyhow).
example attached.
-cw
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="4mingo.c"
/* satan ate my hotdog */
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *buf;
size_t ps;
int f,rl;
ps = getpagesize();
(long)buf = ((unsigned long)malloc(3*ps-1)+ps-1) & -ps;
mprotect(&buf[ps],ps,PROT_NONE);
if((f = open("/dev/zero",O_RDONLY)) == -1){
perror("file open error");
return -1;
}
rl = read(f,buf,2*ps);
if(rl == -1){
perror("couldn't read data");
return -1;
}
printf("read %d bytes\n",rl);
return 0;
}
--0OAP2g/MAC+5xKAE--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/