Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | FUSE: Filesystem in Userspace |
| 3 | Copyright (C) 2001 Miklos Szeredi (mszeredi@inf.bme.hu) |
| 4 | |
| 5 | This program can be distributed under the terms of the GNU GPL. |
| 6 | See the file COPYING. |
| 7 | */ |
| 8 | |
| 9 | #include <fuse.h> |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 10 | |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 11 | #include <unistd.h> |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 12 | #include <time.h> |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 13 | #include <errno.h> |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 14 | |
| 15 | #define UNUSED __attribute__((unused)) |
| 16 | |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 17 | static int null_getattr(const char *path, struct stat *stbuf) |
| 18 | { |
| 19 | if(strcmp(path, "/") != 0) |
| 20 | return -ENOENT; |
| 21 | |
| 22 | stbuf->st_mode = S_IFREG | 0644; |
| 23 | stbuf->st_nlink = 1; |
| 24 | stbuf->st_uid = getuid(); |
| 25 | stbuf->st_gid = getgid(); |
| 26 | stbuf->st_size = (1 << 30); /* 1G */ |
| 27 | stbuf->st_blocks = 0; |
| 28 | stbuf->st_atime = stbuf->st_mtime = stbuf->st_ctime = time(NULL); |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static int null_truncate(const char *path, off_t UNUSED(size)) |
| 34 | { |
| 35 | if(strcmp(path, "/") != 0) |
| 36 | return -ENOENT; |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static int null_open(const char *path, int UNUSED(flags)) |
| 42 | { |
| 43 | if(strcmp(path, "/") != 0) |
| 44 | return -ENOENT; |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static int null_read(const char *path, char *UNUSED(buf), size_t size, |
| 50 | off_t UNUSED(offset)) |
| 51 | { |
| 52 | if(strcmp(path, "/") != 0) |
| 53 | return -ENOENT; |
| 54 | |
| 55 | return size; |
| 56 | } |
| 57 | |
| 58 | static int null_write(const char *path, const char *UNUSED(buf), size_t size, |
| 59 | off_t UNUSED(offset)) |
| 60 | { |
| 61 | if(strcmp(path, "/") != 0) |
| 62 | return -ENOENT; |
| 63 | |
| 64 | return size; |
| 65 | } |
| 66 | |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame^] | 67 | static int null_statfs(struct statfs *st) |
| 68 | { |
| 69 | return st->f_blocks = st->f_bavail = st->f_bsize = st->f_files = |
| 70 | st->f_ffree = st->f_namelen = 0; |
| 71 | } |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 72 | |
| 73 | static struct fuse_operations null_oper = { |
| 74 | getattr: null_getattr, |
| 75 | readlink: NULL, |
| 76 | getdir: NULL, |
| 77 | mknod: NULL, |
| 78 | mkdir: NULL, |
| 79 | symlink: NULL, |
| 80 | unlink: NULL, |
| 81 | rmdir: NULL, |
| 82 | rename: NULL, |
| 83 | link: NULL, |
| 84 | chmod: NULL, |
| 85 | chown: NULL, |
| 86 | truncate: null_truncate, |
| 87 | utime: NULL, |
| 88 | open: null_open, |
| 89 | read: null_read, |
| 90 | write: null_write, |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame^] | 91 | statfs: null_statfs, |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 94 | int main(int argc, char *argv[]) |
| 95 | { |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 96 | fuse_main(argc, argv, &null_oper); |
Miklos Szeredi | 4369643 | 2001-11-18 19:15:05 +0000 | [diff] [blame] | 97 | return 0; |
| 98 | } |