1 /* $NetBSD: v7fs_impl.h,v 1.1 2011/06/27 11:52:25 uch Exp $ */
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 /* V7FS implementation. */
39 #define KDASSERT(x) assert(x)
44 bool (*drive
)(void *, uint8_t);
45 bool (*read
)(void *, uint8_t *, daddr_t
);
46 bool (*read_n
)(void *, uint8_t *, daddr_t
, int);
47 bool (*write
)(void *, uint8_t *, daddr_t
);
48 bool (*write_n
)(void *, uint8_t *, daddr_t
, int);
52 struct endian_conversion_ops
{
53 uint32_t (*conv32
)(uint32_t);
54 uint16_t (*conv16
)(uint16_t);
55 /* For daddr packing */
56 v7fs_daddr_t (*conv24read
)(uint8_t *);
57 void (*conv24write
)(v7fs_daddr_t
, uint8_t *);
67 void (*unlock
)(void *);
69 #define SUPERB_LOCK(x) ((x)->sb_lock.lock((x)->sb_lock.cookie))
70 #define SUPERB_UNLOCK(x) ((x)->sb_lock.unlock((x)->sb_lock.cookie))
71 #define ILIST_LOCK(x) ((x)->ilist_lock.lock((x)->ilist_lock.cookie))
72 #define ILIST_UNLOCK(x) ((x)->ilist_lock.unlock((x)->ilist_lock.cookie))
73 #define MEM_LOCK(x) ((x)->mem_lock.lock((x)->mem_lock.cookie))
74 #define MEM_UNLOCK(x) ((x)->mem_lock.unlock((x)->mem_lock.cookie))
76 #define SUPERB_LOCK(x) ((void)0)
77 #define SUPERB_UNLOCK(x) ((void)0)
78 #define ILIST_LOCK(x) ((void)0)
79 #define ILIST_UNLOCK(x) ((void)0)
80 #define MEM_LOCK(x) ((void)0)
81 #define MEM_UNLOCK(x) ((void)0)
92 struct v7fs_fileattr
{
103 #define V7FS_SELF_NSCRATCH 3
104 uint8_t scratch
[V7FS_SELF_NSCRATCH
][V7FS_BSIZE
];
105 int scratch_free
; /* free block bitmap. */
106 int scratch_remain
; /* for statistic */
107 struct block_io_ops io
;
109 struct endian_conversion_ops val
;
112 /* in-core superblock access. (freeblock/freeinode) split? -uch */
113 struct lock_ops sb_lock
;
114 struct lock_ops ilist_lock
; /* disk ilist access. */
115 struct lock_ops mem_lock
; /* work memory allocation lock. */
117 struct v7fs_superblock superblock
;
118 struct v7fs_stat stat
;
122 struct v7fs_mount_device
{
124 void *vnode
; /* NetBSD kernel */
125 int fd
; /* NetBSD newfs,fsck */
126 const char *filename
;/* misc test */
128 daddr_t sectors
; /*total size in sector. */
132 #define V7FS_ITERATOR_BREAK (-1)
133 #define V7FS_ITERATOR_END (-2)
134 #define V7FS_ITERATOR_ERROR (-3)
136 int v7fs_io_init(struct v7fs_self
**, const struct v7fs_mount_device
*, size_t);
137 void v7fs_io_fini(struct v7fs_self
*);
138 void *scratch_read(struct v7fs_self
*, daddr_t
);
139 void scratch_free(struct v7fs_self
*, void *);
140 int scratch_remain(const struct v7fs_self
*);
144 #define V7FS_IO_DEBUG
145 #define V7FS_SUPERBLOCK_DEBUG
146 #define V7FS_DATABLOCK_DEBUG
147 #define V7FS_INODE_DEBUG
148 #define V7FS_DIRENT_DEBUG
149 #define V7FS_FILE_DEBUG
150 #define V7FS_VFSOPS_DEBUG
151 #define V7FS_VNOPS_DEBUG
154 #endif /*!_V7FS_IMPL_H_ */