/[fuse_dbi]/fuse/trunk/example/null.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /fuse/trunk/example/null.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Wed Aug 4 11:36:44 2004 UTC (19 years, 10 months ago) by dpavlin
Original Path: fuse/cvs/example/null.c
File MIME type: text/plain
File size: 1676 byte(s)
import current CVS of fuse

1 dpavlin 4 /*
2     FUSE: Filesystem in Userspace
3     Copyright (C) 2001-2004 Miklos Szeredi <miklos@szeredi.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>
10     #include <string.h>
11     #include <unistd.h>
12     #include <time.h>
13     #include <errno.h>
14    
15     #define UNUSED(x) x __attribute__((unused))
16    
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 = (1ULL << 32); /* 4G */
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    
67     static struct fuse_operations null_oper = {
68     .getattr = null_getattr,
69     .truncate = null_truncate,
70     .open = null_open,
71     .read = null_read,
72     .write = null_write,
73     };
74    
75     int main(int argc, char *argv[])
76     {
77     fuse_main(argc, argv, &null_oper);
78     return 0;
79     }

  ViewVC Help
Powered by ViewVC 1.1.26