PageRenderTime 33ms CodeModel.GetById 22ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/common/unixfs/unixfs_common.h

http://macfuse.googlecode.com/
C++ Header | 69 lines | 52 code | 6 blank | 11 comment | 0 complexity | 9869fe677c13e643a1b9368eeb75ae8d MD5 | raw file
 1/*
 2 * UnixFS
 3 *
 4 * A general-purpose file system layer for writing/reimplementing/porting
 5 * Unix file systems through MacFUSE.
 6
 7 * Copyright (c) 2008 Amit Singh. All Rights Reserved.
 8 * http://osxbook.com
 9 */
10
11#ifndef _UNIXFS_COMMON_H_
12#define _UNIXFS_COMMON_H_
13
14/* Implementation of Ancient Unix file system internals. */
15
16static void*         unixfs_internal_init(const char* dmg, uint32_t flags,
17                                          fs_endian_t fse, char** fsname,
18                                          char** volname);
19static void          unixfs_internal_fini(void*);
20static off_t         unixfs_internal_alloc(void);
21static off_t         unixfs_internal_bmap(struct inode* ip, off_t lblkno,
22                                         int* error);
23static int           unixfs_internal_bread(off_t blkno, char *blkbuf);
24static struct inode* unixfs_internal_iget(ino_t ino);
25static void          unixfs_internal_iput(struct inode* ip);
26static int           unixfs_internal_igetattr(ino_t ino, struct stat *stbuf);
27static void          unixfs_internal_istat(struct inode* ip,
28                                           struct stat* stbuf);
29static int           unixfs_internal_namei(ino_t parentino, const char *name,
30                                           struct stat* stbuf);
31static int           unixfs_internal_nextdirentry(struct inode* ip,
32                                                  struct unixfs_dirbuf* dirbuf,
33                                                  off_t* offset,
34                                                  struct unixfs_direntry* dent);
35static ssize_t       unixfs_internal_pbread(struct inode* ip, char* buf,
36                                            size_t nbyte, off_t offset,
37                                            int* error);
38static int           unixfs_internal_sanitycheck(void* filsys, off_t disksize);
39static int           unixfs_internal_readlink(ino_t ino,
40                                              char path[UNIXFS_MAXPATHLEN]);
41static int           unixfs_internal_statvfs(struct statvfs* svb);
42
43/* To be used in file-system-specific code. */
44
45#define DECL_UNIXFS(fsname, sufx)                     \
46    static struct unixfs_ops ops_##sufx = {           \
47        .init         = unixfs_internal_init,         \
48        .fini         = unixfs_internal_fini,         \
49        .alloc        = unixfs_internal_alloc,        \
50        .bmap         = unixfs_internal_bmap,         \
51        .bread        = unixfs_internal_bread,        \
52        .iget         = unixfs_internal_iget,         \
53        .iput         = unixfs_internal_iput,         \
54        .igetattr     = unixfs_internal_igetattr,     \
55        .istat        = unixfs_internal_istat,        \
56        .namei        = unixfs_internal_namei,        \
57        .nextdirentry = unixfs_internal_nextdirentry, \
58        .pbread       = unixfs_internal_pbread,       \
59        .readlink     = unixfs_internal_readlink,     \
60        .sanitycheck  = unixfs_internal_sanitycheck,  \
61        .statvfs      = unixfs_internal_statvfs,      \
62    };                                                \
63    struct unixfs unixfs_##sufx = {                   \
64        &ops_##sufx, NULL, -1, 0                      \
65    };                                                \
66    static struct super_block* unixfs = NULL;         \
67    static const char* unixfs_fstype = fsname;
68
69#endif /* _UNIXFS_COMMON_H_ */