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