Re: PROBLEM: 2.6.35.7 to 3.0 Inotify events missing
From: Sylvain Rochet
Date: Thu Aug 25 2011 - 17:47:24 EST
Hi,
On Sat, Aug 20, 2011 at 12:37:56AM +0100, Jamie Lokier wrote:
>
> Can it also be bypassed with sys_open_by_handle_at?
Just checked that and... as planned it can be bypassed with
name_to_handle_at/open_by_handle_at as well.
(I added my quick'n'dirty test code, maybe someone will be interested by
a working fhandle example on Linux 3.0.x).
Sylvain
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
struct file_handle {
int handle_size;
int handle_type;
void *f_handle;
};
int main(int argc, char *argv[])
{
int ret;
int fd;
int mntfd;
struct file_handle fh;
fh.handle_type = 0;
fh.f_handle = malloc(100);
fh.handle_size = 100/sizeof(int);
errno = 0;
printf("%s\n", argv[1]);
int mntid = 20;
ret = syscall(303, 0, argv[1], &fh, &mntid, 0);
if (ret) {
perror("303 Error:");
exit(1);
}
printf("%d - %d\n", mntid, fh.handle_size);
printf("sleep\n");
sleep(60);
mntfd = open("/data", O_RDONLY);
printf("dir = %d\n", mntfd );
fd = syscall(304, mntfd, &fh, O_WRONLY);
if (fd < 0 ) {
perror("304 Error:");
exit(1);
}
printf("fd = %d\n", fd);
write(fd, "toto", 4);
if( close(fd) ) {
printf("close failed\n");
}
return 0;
}
Attachment:
signature.asc
Description: Digital signature