blob: 71e9a19de7fe01e9847b98eb570458fed94a5981 [file] [log] [blame]
Miklos Szeredi43696432001-11-18 19:15:05 +00001/*
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 Szeredicc8c9752001-11-21 10:03:39 +000010
Miklos Szeredi43696432001-11-18 19:15:05 +000011#include <unistd.h>
Miklos Szeredi43696432001-11-18 19:15:05 +000012#include <time.h>
Miklos Szeredicc8c9752001-11-21 10:03:39 +000013#include <errno.h>
Miklos Szeredi43696432001-11-18 19:15:05 +000014
15#define UNUSED __attribute__((unused))
16
Miklos Szeredi43696432001-11-18 19:15:05 +000017static 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
33static 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
41static int null_open(const char *path, int UNUSED(flags))
42{
43 if(strcmp(path, "/") != 0)
44 return -ENOENT;
45
46 return 0;
47}
48
49static 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
58static 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 Glinesd84b39a2002-01-07 16:32:02 +000067static 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 Szeredi43696432001-11-18 19:15:05 +000072
73static 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 Glinesd84b39a2002-01-07 16:32:02 +000091 statfs: null_statfs,
Miklos Szeredi43696432001-11-18 19:15:05 +000092};
93
Miklos Szeredi43696432001-11-18 19:15:05 +000094int main(int argc, char *argv[])
95{
Miklos Szeredicc8c9752001-11-21 10:03:39 +000096 fuse_main(argc, argv, &null_oper);
Miklos Szeredi43696432001-11-18 19:15:05 +000097 return 0;
98}