PageRenderTime 56ms CodeModel.GetById 40ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/core/sdk-objc/ProjectTemplates/C Command Line File System/TemplateFS.c

http://macfuse.googlecode.com/
C | 217 lines | 171 code | 34 blank | 12 comment | 4 complexity | 49f1df6df33ab8897d950930b1400964 MD5 | raw file
  1/*
  2 * ÇPROJECTNAMEASIDENTIFIERÈ.c
  3 * ÇPROJECTNAMEÈ
  4 *
  5 * Created by ÇFULLUSERNAMEÈ on ÇDATEÈ.
  6 * Copyright ÇYEARÈ ÇORGANIZATIONNAMEÈ. All rights reserved.
  7 *
  8 */
  9
 10#include <fuse.h>
 11#include <string.h>
 12#include <errno.h>
 13#include <sys/stat.h>
 14
 15static int
 16ÇPROJECTNAMEASIDENTIFIERÈ_fgetattr(const char *path, struct stat *stbuf,
 17                  struct fuse_file_info *fi) {
 18  memset(stbuf, 0, sizeof(struct stat));
 19  
 20  if (strcmp(path, "/") == 0) { /* The root directory of our file system. */
 21    stbuf->st_mode = S_IFDIR | 0755;
 22    stbuf->st_nlink = 3;
 23    return 0;
 24  }
 25  return -ENOENT;
 26}
 27
 28static int
 29ÇPROJECTNAMEASIDENTIFIERÈ_getattr(const char *path, struct stat *stbuf) {
 30  return ÇPROJECTNAMEASIDENTIFIERÈ_fgetattr(path, stbuf, NULL);
 31}
 32
 33static int
 34ÇPROJECTNAMEASIDENTIFIERÈ_readlink(const char *path, char *buf, size_t size) {
 35  return -ENOENT;
 36}
 37
 38static int
 39ÇPROJECTNAMEASIDENTIFIERÈ_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 40                 off_t offset, struct fuse_file_info *fi) {
 41  if (strcmp(path, "/") != 0) /* We only recognize the root directory. */
 42    return -ENOENT;
 43  
 44  filler(buf, ".", NULL, 0);           /* Current directory (.)  */
 45  filler(buf, "..", NULL, 0);          /* Parent directory (..)  */
 46  
 47  return 0;
 48}
 49
 50static int
 51ÇPROJECTNAMEASIDENTIFIERÈ_mknod(const char *path, mode_t mode, dev_t rdev) {
 52  return -ENOSYS;
 53}
 54
 55static int
 56ÇPROJECTNAMEASIDENTIFIERÈ_mkdir(const char *path, mode_t mode) {
 57  return -ENOSYS;
 58}
 59
 60static int
 61ÇPROJECTNAMEASIDENTIFIERÈ_unlink(const char *path) {
 62  return -ENOSYS;
 63}
 64
 65static int
 66ÇPROJECTNAMEASIDENTIFIERÈ_rmdir(const char *path) {
 67  return -ENOSYS;
 68}
 69
 70static int
 71ÇPROJECTNAMEASIDENTIFIERÈ_symlink(const char *from, const char *to) {
 72  return -ENOSYS;
 73}
 74
 75static int
 76ÇPROJECTNAMEASIDENTIFIERÈ_rename(const char *from, const char *to) {
 77  return -ENOSYS;
 78}
 79
 80static int
 81ÇPROJECTNAMEASIDENTIFIERÈ_exchange(const char *path1, const char *path2, unsigned long options) {
 82  return -ENOSYS;
 83}
 84
 85static int
 86ÇPROJECTNAMEASIDENTIFIERÈ_link(const char *from, const char *to) {
 87  return -ENOSYS;
 88}
 89
 90static int
 91ÇPROJECTNAMEASIDENTIFIERÈ_fsetattr_x(const char *path, struct setattr_x *attr,
 92                    struct fuse_file_info *fi) {
 93  return -ENOENT;
 94}
 95
 96static int
 97ÇPROJECTNAMEASIDENTIFIERÈ_setattr_x(const char *path, struct setattr_x *attr) {
 98  return -ENOENT;
 99}
100
101static int
102ÇPROJECTNAMEASIDENTIFIERÈ_getxtimes(const char *path, struct timespec *bkuptime,
103                   struct timespec *crtime) {
104  return -ENOENT;
105}
106
107static int
108ÇPROJECTNAMEASIDENTIFIERÈ_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
109  return -ENOSYS;
110}
111
112static int
113ÇPROJECTNAMEASIDENTIFIERÈ_open(const char *path, struct fuse_file_info *fi) {
114  return -ENOENT;
115}
116
117static int
118ÇPROJECTNAMEASIDENTIFIERÈ_read(const char *path, char *buf, size_t size, off_t offset,
119              struct fuse_file_info *fi) {
120  return -ENOSYS;
121}
122
123static int
124ÇPROJECTNAMEASIDENTIFIERÈ_write(const char *path, const char *buf, size_t size,
125               off_t offset, struct fuse_file_info *fi) {
126  return -ENOSYS;
127}
128
129static int
130ÇPROJECTNAMEASIDENTIFIERÈ_statfs(const char *path, struct statvfs *stbuf) {
131  memset(stbuf, 0, sizeof(*stbuf));
132  stbuf->f_files = 2;  /* For . and .. in the root */
133  return 0;
134}
135
136static int
137ÇPROJECTNAMEASIDENTIFIERÈ_flush(const char *path, struct fuse_file_info *fi) {
138  return 0;
139}
140
141static int
142ÇPROJECTNAMEASIDENTIFIERÈ_release(const char *path, struct fuse_file_info *fi) {
143  return 0;
144}
145
146static int
147ÇPROJECTNAMEASIDENTIFIERÈ_fsync(const char *path, int isdatasync, struct fuse_file_info *fi) {
148  return 0;
149}
150
151static int
152ÇPROJECTNAMEASIDENTIFIERÈ_setxattr(const char *path, const char *name, const char *value,
153                  size_t size, int flags, uint32_t position) {
154  return -ENOTSUP;
155 }
156
157static int
158ÇPROJECTNAMEASIDENTIFIERÈ_getxattr(const char *path, const char *name, char *value, size_t size,
159                  uint32_t position) {
160  return -ENOATTR;
161}
162
163static int
164ÇPROJECTNAMEASIDENTIFIERÈ_listxattr(const char *path, char *list, size_t size) {
165  return 0;
166}
167
168static int
169ÇPROJECTNAMEASIDENTIFIERÈ_removexattr(const char *path, const char *name) {
170  return -ENOATTR;
171}
172
173void *
174ÇPROJECTNAMEASIDENTIFIERÈ_init(struct fuse_conn_info *conn) {
175  FUSE_ENABLE_XTIMES(conn);
176  return NULL;
177}
178
179void
180ÇPROJECTNAMEASIDENTIFIERÈ_destroy(void *userdata) {
181  /* nothing */
182}
183
184struct fuse_operations ÇPROJECTNAMEASIDENTIFIERÈ_operations = {
185  .init        = ÇPROJECTNAMEASIDENTIFIERÈ_init,
186  .destroy     = ÇPROJECTNAMEASIDENTIFIERÈ_destroy,
187  .getattr     = ÇPROJECTNAMEASIDENTIFIERÈ_getattr,
188  .fgetattr    = ÇPROJECTNAMEASIDENTIFIERÈ_fgetattr,
189/*  .access      = ÇPROJECTNAMEASIDENTIFIERÈ_access, */
190  .readlink    = ÇPROJECTNAMEASIDENTIFIERÈ_readlink,
191/*  .opendir     = ÇPROJECTNAMEASIDENTIFIERÈ_opendir, */
192  .readdir     = ÇPROJECTNAMEASIDENTIFIERÈ_readdir,
193/*  .releasedir  = ÇPROJECTNAMEASIDENTIFIERÈ_releasedir, */
194  .mknod       = ÇPROJECTNAMEASIDENTIFIERÈ_mknod,
195  .mkdir       = ÇPROJECTNAMEASIDENTIFIERÈ_mkdir,
196  .symlink     = ÇPROJECTNAMEASIDENTIFIERÈ_symlink,
197  .unlink      = ÇPROJECTNAMEASIDENTIFIERÈ_unlink,
198  .rmdir       = ÇPROJECTNAMEASIDENTIFIERÈ_rmdir,
199  .rename      = ÇPROJECTNAMEASIDENTIFIERÈ_rename,
200  .link        = ÇPROJECTNAMEASIDENTIFIERÈ_link,
201  .create      = ÇPROJECTNAMEASIDENTIFIERÈ_create,
202  .open        = ÇPROJECTNAMEASIDENTIFIERÈ_open,
203  .read        = ÇPROJECTNAMEASIDENTIFIERÈ_read,
204  .write       = ÇPROJECTNAMEASIDENTIFIERÈ_write,
205  .statfs      = ÇPROJECTNAMEASIDENTIFIERÈ_statfs,
206  .flush       = ÇPROJECTNAMEASIDENTIFIERÈ_flush,
207  .release     = ÇPROJECTNAMEASIDENTIFIERÈ_release,
208  .fsync       = ÇPROJECTNAMEASIDENTIFIERÈ_fsync,
209  .setxattr    = ÇPROJECTNAMEASIDENTIFIERÈ_setxattr,
210  .getxattr    = ÇPROJECTNAMEASIDENTIFIERÈ_getxattr,
211  .listxattr   = ÇPROJECTNAMEASIDENTIFIERÈ_listxattr,
212  .removexattr = ÇPROJECTNAMEASIDENTIFIERÈ_removexattr,
213  .exchange    = ÇPROJECTNAMEASIDENTIFIERÈ_exchange,
214  .getxtimes   = ÇPROJECTNAMEASIDENTIFIERÈ_getxtimes,
215  .setattr_x   = ÇPROJECTNAMEASIDENTIFIERÈ_setattr_x,
216  .fsetattr_x  = ÇPROJECTNAMEASIDENTIFIERÈ_fsetattr_x,
217};