1 /* $NetBSD: dtfs.h,v 1.20 2007/07/27 08:29:10 pooka Exp $ */
4 * Copyright (c) 2006 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/types.h>
36 int dtfs_domount(struct puffs_usermount
*, const char *);
38 #define DTFS_BLOCKSHIFT (12)
39 #define DTFS_BLOCKSIZE (1<<DTFS_BLOCKSHIFT)
41 #define ROUNDUP(a,b) ((a) & ((b)-1))
42 #define BLOCKNUM(a,b) (((a) & ~((1<<(b))-1)) >> (b))
46 ino_t dtm_nextfileid
; /* running number for file id */
48 size_t dtm_fsizes
; /* sum of file sizes in bytes */
49 fsfilcnt_t dtm_nfiles
; /* number of files */
51 LIST_HEAD(, dtfs_poll
) dtm_pollent
;
53 vm_prot_t dtm_allowprot
;
64 struct puffs_node
*dotdot
;
65 LIST_HEAD(, dtfs_dirent
) dirents
;
71 #define df_blocks u.reg.blocks
72 #define df_numblocks u.reg.numblocks
73 #define df_datalen u.reg.datalen
74 #define df_dotdot u.dir.dotdot
75 #define df_dirents u.dir.dirents
76 #define df_linktarget u.link.target
80 struct puffs_node
*dfd_node
;
81 struct puffs_node
*dfd_parent
;
85 LIST_ENTRY(dtfs_dirent
) dfd_entries
;
89 struct puffs_node
*dfid_addr
;
91 /* best^Wsome-effort extra sanity check */
95 #define DTFS_FIDSIZE (sizeof(struct dtfs_fid))
98 struct puffs_cc
*dp_pcc
;
99 LIST_ENTRY(dtfs_poll
) dp_entries
;
102 struct puffs_node
* dtfs_genfile(struct puffs_node
*,
103 const struct puffs_cn
*, enum vtype
);
104 struct dtfs_file
* dtfs_newdir(void);
105 struct dtfs_file
* dtfs_newfile(void);
106 struct dtfs_dirent
* dtfs_dirgetnth(struct dtfs_file
*, int);
107 struct dtfs_dirent
* dtfs_dirgetbyname(struct dtfs_file
*,
108 const char *, size_t);
110 void dtfs_nukenode(struct puffs_node
*, struct puffs_node
*,
111 const char *, size_t);
112 void dtfs_freenode(struct puffs_node
*);
113 void dtfs_setsize(struct puffs_node
*, off_t
);
115 void dtfs_adddent(struct puffs_node
*, struct dtfs_dirent
*);
116 void dtfs_removedent(struct puffs_node
*, struct dtfs_dirent
*);
118 void dtfs_baseattrs(struct vattr
*, enum vtype
, ino_t
);
119 void dtfs_updatetimes(struct puffs_node
*, int, int, int);
122 #define DTFS_CTOF(a) ((struct dtfs_file *)(((struct puffs_node *)a)->pn_data))
123 #define DTFS_PTOF(a) ((struct dtfs_file *)(a->pn_data))