2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU GPL.
8 gcc -Wall null.c `pkg-config fuse --cflags --libs` -o null
11 #define FUSE_USE_VERSION 26
19 static int null_getattr(const char *path
, struct stat
*stbuf
)
21 if(strcmp(path
, "/") != 0)
24 stbuf
->st_mode
= S_IFREG
| 0644;
26 stbuf
->st_uid
= getuid();
27 stbuf
->st_gid
= getgid();
28 stbuf
->st_size
= (1ULL << 32); /* 4G */
30 stbuf
->st_atime
= stbuf
->st_mtime
= stbuf
->st_ctime
= time(NULL
);
35 static int null_truncate(const char *path
, off_t size
)
39 if(strcmp(path
, "/") != 0)
45 static int null_open(const char *path
, struct fuse_file_info
*fi
)
49 if(strcmp(path
, "/") != 0)
55 static int null_read(const char *path
, char *buf
, size_t size
,
56 off_t offset
, struct fuse_file_info
*fi
)
62 if(strcmp(path
, "/") != 0)
65 if (offset
>= (1ULL << 32))
71 static int null_write(const char *path
, const char *buf
, size_t size
,
72 off_t offset
, struct fuse_file_info
*fi
)
78 if(strcmp(path
, "/") != 0)
84 static struct fuse_operations null_oper
= {
85 .getattr
= null_getattr
,
86 .truncate
= null_truncate
,
92 int main(int argc
, char *argv
[])
94 return fuse_main(argc
, argv
, &null_oper
, NULL
);