1 1.1 uch /* $NetBSD: v7fs_inode.h,v 1.1 2011/06/27 11:52:25 uch Exp $ */ 2 1.1 uch 3 1.1 uch /*- 4 1.1 uch * Copyright (c) 2011 The NetBSD Foundation, Inc. 5 1.1 uch * All rights reserved. 6 1.1 uch * 7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation 8 1.1 uch * by UCHIYAMA Yasushi. 9 1.1 uch * 10 1.1 uch * Redistribution and use in source and binary forms, with or without 11 1.1 uch * modification, are permitted provided that the following conditions 12 1.1 uch * are met: 13 1.1 uch * 1. Redistributions of source code must retain the above copyright 14 1.1 uch * notice, this list of conditions and the following disclaimer. 15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 uch * notice, this list of conditions and the following disclaimer in the 17 1.1 uch * documentation and/or other materials provided with the distribution. 18 1.1 uch * 19 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 uch * POSSIBILITY OF SUCH DAMAGE. 30 1.1 uch */ 31 1.1 uch 32 1.1 uch #ifndef _V7FS_INODE_H_ 33 1.1 uch #define _V7FS_INODE_H_ 34 1.1 uch 35 1.1 uch /* Software implementation of inode. (memory image) */ 36 1.1 uch struct v7fs_inode { 37 1.1 uch v7fs_ino_t inode_number; /* inode location */ 38 1.1 uch /* attr */ 39 1.1 uch uint16_t mode; 40 1.1 uch int16_t nlink; 41 1.1 uch int16_t uid; 42 1.1 uch int16_t gid; 43 1.1 uch v7fs_time_t atime; 44 1.1 uch v7fs_time_t mtime; 45 1.1 uch v7fs_time_t ctime; 46 1.1 uch /* open mode */ 47 1.1 uch bool append_mode; 48 1.1 uch 49 1.1 uch v7fs_dev_t device; /* for special file.(cdev, bdev) */ 50 1.1 uch /* payload. */ 51 1.1 uch v7fs_off_t filesize; /* size of file (byte) */ 52 1.1 uch v7fs_daddr_t addr[V7FS_NADDR]; /* data block address list */ 53 1.1 uch }; 54 1.1 uch 55 1.1 uch #define v7fs_inode_filesize(i) ((i)->filesize) 56 1.1 uch #define v7fs_inode_allocated(i) ((i)->mode) 57 1.1 uch #define v7fs_inode_nlink(i) ((i)->nlink) 58 1.1 uch /* V7 original */ 59 1.1 uch #define v7fs_inode_isdir(i) (((i)->mode & V7FS_IFMT) == V7FS_IFDIR) 60 1.1 uch #define v7fs_inode_isfile(i) (((i)->mode & V7FS_IFMT) == V7FS_IFREG) 61 1.1 uch #define v7fs_inode_iscdev(i) (((i)->mode & V7FS_IFMT) == V7FS_IFCHR) 62 1.1 uch #define v7fs_inode_isbdev(i) (((i)->mode & V7FS_IFMT) == V7FS_IFBLK) 63 1.1 uch /* 2BSD extension (implementation is different) */ 64 1.1 uch #define v7fs_inode_islnk(i) (((i)->mode & V7FS_IFMT) == V7FSBSD_IFLNK) 65 1.1 uch #define v7fs_inode_issock(i) (((i)->mode & V7FS_IFMT) == V7FSBSD_IFSOCK) 66 1.1 uch /* NetBSD Extension */ 67 1.1 uch #define v7fs_inode_isfifo(i) (((i)->mode & V7FS_IFMT) == V7FSBSD_IFFIFO) 68 1.1 uch 69 1.1 uch __BEGIN_DECLS 70 1.1 uch /* Free inode access ops. */ 71 1.1 uch int v7fs_inode_allocate(struct v7fs_self *, v7fs_ino_t *); 72 1.1 uch void v7fs_inode_deallocate(struct v7fs_self *, v7fs_ino_t); 73 1.1 uch 74 1.1 uch /* Disk I/O ops. */ 75 1.1 uch int v7fs_inode_load(struct v7fs_self *, struct v7fs_inode *, v7fs_ino_t); 76 1.1 uch int v7fs_inode_writeback(struct v7fs_self *, struct v7fs_inode *); 77 1.1 uch void v7fs_inode_setup_memory_image(const struct v7fs_self *, 78 1.1 uch struct v7fs_inode *, struct v7fs_inode_diskimage *); 79 1.1 uch 80 1.1 uch /* Check. */ 81 1.1 uch int v7fs_inode_number_sanity(const struct v7fs_superblock *, v7fs_ino_t); 82 1.1 uch 83 1.1 uch /* Util. */ 84 1.1 uch void v7fs_inode_chmod(struct v7fs_inode *, v7fs_mode_t); 85 1.1 uch void v7fs_inode_dump(const struct v7fs_inode *); 86 1.1 uch 87 1.1 uch /* Loop over all inode in ilist. */ 88 1.1 uch int v7fs_ilist_foreach(struct v7fs_self *, int (*)(struct v7fs_self *, void *, 89 1.1 uch struct v7fs_inode *, v7fs_ino_t), void *); 90 1.1 uch __END_DECLS 91 1.1 uch #endif /*!_V7FS_INODE_H_ */ 92