blob: d9539ab1fb87d2592167e55fff3d9cdf4f1757fd [file] [log] [blame]
Miklos Szeredi43696432001-11-18 19:15:05 +00001/*
2 FUSE: Filesystem in Userspace
Miklos Szeredi149f6072005-01-10 12:29:28 +00003 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
Miklos Szeredi43696432001-11-18 19:15:05 +00004
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 Szeredi074b4b92002-01-11 08:25:52 +000010#include <string.h>
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
Miklos Szeredi43696432001-11-18 19:15:05 +000015static int null_getattr(const char *path, struct stat *stbuf)
16{
17 if(strcmp(path, "/") != 0)
18 return -ENOENT;
Miklos Szeredie5183742005-02-02 11:14:04 +000019
Miklos Szeredi43696432001-11-18 19:15:05 +000020 stbuf->st_mode = S_IFREG | 0644;
21 stbuf->st_nlink = 1;
22 stbuf->st_uid = getuid();
23 stbuf->st_gid = getgid();
Miklos Szeredi307242f2004-01-26 11:28:44 +000024 stbuf->st_size = (1ULL << 32); /* 4G */
Miklos Szeredi43696432001-11-18 19:15:05 +000025 stbuf->st_blocks = 0;
26 stbuf->st_atime = stbuf->st_mtime = stbuf->st_ctime = time(NULL);
27
28 return 0;
29}
30
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000031static int null_truncate(const char *path, off_t size)
Miklos Szeredi43696432001-11-18 19:15:05 +000032{
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000033 (void) size;
34
Miklos Szeredi43696432001-11-18 19:15:05 +000035 if(strcmp(path, "/") != 0)
36 return -ENOENT;
37
38 return 0;
39}
40
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000041static int null_open(const char *path, struct fuse_file_info *fi)
Miklos Szeredi43696432001-11-18 19:15:05 +000042{
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000043 (void) fi;
44
Miklos Szeredi43696432001-11-18 19:15:05 +000045 if(strcmp(path, "/") != 0)
46 return -ENOENT;
47
48 return 0;
49}
50
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000051static int null_read(const char *path, char *buf, size_t size,
52 off_t offset, struct fuse_file_info *fi)
Miklos Szeredi43696432001-11-18 19:15:05 +000053{
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000054 (void) buf;
55 (void) offset;
56 (void) fi;
57
Miklos Szeredi43696432001-11-18 19:15:05 +000058 if(strcmp(path, "/") != 0)
59 return -ENOENT;
60
61 return size;
62}
63
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000064static int null_write(const char *path, const char *buf, size_t size,
65 off_t offset, struct fuse_file_info *fi)
Miklos Szeredi43696432001-11-18 19:15:05 +000066{
Miklos Szeredif6e0ec62005-08-03 09:11:06 +000067 (void) buf;
68 (void) offset;
69 (void) fi;
70
Miklos Szeredi43696432001-11-18 19:15:05 +000071 if(strcmp(path, "/") != 0)
72 return -ENOENT;
73
74 return size;
75}
76
Miklos Szeredi43696432001-11-18 19:15:05 +000077static struct fuse_operations null_oper = {
Miklos Szeredie8663f32004-01-13 15:33:12 +000078 .getattr = null_getattr,
79 .truncate = null_truncate,
80 .open = null_open,
81 .read = null_read,
82 .write = null_write,
Miklos Szeredi43696432001-11-18 19:15:05 +000083};
84
Miklos Szeredi43696432001-11-18 19:15:05 +000085int main(int argc, char *argv[])
86{
Miklos Szeredi5dc8a802004-10-21 09:35:10 +000087 return fuse_main(argc, argv, &null_oper);
Miklos Szeredi43696432001-11-18 19:15:05 +000088}