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.
11 * null.c - FUSE: Filesystem in Userspace
13 * \section section_compile compiling this example
15 * gcc -Wall null.c `pkg-config fuse3 --cflags --libs` -o null
17 * \section section_source the complete source
22 #define FUSE_USE_VERSION 30
32 static int null_getattr(const char *path
, struct stat
*stbuf
)
34 if(strcmp(path
, "/") != 0)
37 stbuf
->st_mode
= S_IFREG
| 0644;
39 stbuf
->st_uid
= getuid();
40 stbuf
->st_gid
= getgid();
41 stbuf
->st_size
= (1ULL << 32); /* 4G */
43 stbuf
->st_atime
= stbuf
->st_mtime
= stbuf
->st_ctime
= time(NULL
);
48 static int null_truncate(const char *path
, off_t size
)
52 if(strcmp(path
, "/") != 0)
58 static int null_open(const char *path
, struct fuse_file_info
*fi
)
62 if(strcmp(path
, "/") != 0)
68 static int null_read(const char *path
, char *buf
, size_t size
,
69 off_t offset
, struct fuse_file_info
*fi
)
75 if(strcmp(path
, "/") != 0)
78 if (offset
>= (1ULL << 32))
84 static int null_write(const char *path
, const char *buf
, size_t size
,
85 off_t offset
, struct fuse_file_info
*fi
)
91 if(strcmp(path
, "/") != 0)
97 static struct fuse_operations null_oper
= {
98 .getattr
= null_getattr
,
99 .truncate
= null_truncate
,
105 int main(int argc
, char *argv
[])
107 return fuse_main(argc
, argv
, &null_oper
, NULL
);