bf92417b901312f69b80e8b963e4b4a5f2958b9a
[dragonfly.git] / sys / vfs / isofs / cd9660 / cd9660_node.h
1 /*-
2  * Copyright (c) 1994
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley
6  * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
7  * Support code is derived from software contributed to Berkeley
8  * by Atsushi Murai (amurai@spec.co.jp).
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
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.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the University of
21  *      California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *      @(#)cd9660_node.h       8.6 (Berkeley) 5/14/95
39  * $FreeBSD: src/sys/isofs/cd9660/cd9660_node.h,v 1.20 1999/12/29 04:54:37 peter Exp $
40  * $DragonFly: src/sys/vfs/isofs/cd9660/cd9660_node.h,v 1.7 2005/09/14 01:13:37 dillon Exp $
41  */
42
43 #include <sys/lockf.h>
44
45 /*
46  * Theoretically, directories can be more than 2Gb in length,
47  * however, in practice this seems unlikely. So, we define
48  * the type doff_t as a long to keep down the cost of doing
49  * lookup on a 32-bit machine. If you are porting to a 64-bit
50  * architecture, you should make doff_t the same as off_t.
51  */
52 #define doff_t  long
53
54 typedef struct  {
55         struct timespec iso_atime;      /* time of last access */
56         struct timespec iso_mtime;      /* time of last modification */
57         struct timespec iso_ctime;      /* time file changed */
58         u_short         iso_mode;       /* files access mode and type */
59         uid_t           iso_uid;        /* owner user id */
60         gid_t           iso_gid;        /* owner group id */
61         short           iso_links;      /* links of file */
62         udev_t          iso_rdev;       /* Major/Minor number for special */
63 } ISO_RRIP_INODE;
64
65
66 struct iso_node {
67         struct  iso_node *i_next; /* hash chain */
68         struct  vnode *i_vnode; /* vnode associated with this inode */
69         struct  vnode *i_devvp; /* vnode for block I/O */
70         u_long  i_flag;         /* see below */
71         dev_t   i_dev;          /* device where inode resides */
72         ino_t   i_number;       /* the identity of the inode */
73                                 /* we use the actual starting block of the file */
74         struct  iso_mnt *i_mnt; /* filesystem associated with this inode */
75         struct  lockf i_lockf;  /* head of byte-level lock list */
76         doff_t  i_endoff;       /* end of useful stuff in directory */
77         doff_t  i_diroff;       /* offset in dir, where we found last entry */
78         doff_t  i_offset;       /* offset of free space in directory */
79         ino_t   i_ino;          /* inode number of found directory */
80
81         long iso_extent;        /* extent of file */
82         long i_size;
83         long iso_start;         /* actual start of data of file (may be different */
84                                 /* from iso_extent, if file has extended attributes) */
85         ISO_RRIP_INODE  inode;
86 };
87
88 #define i_forw          i_chain[0]
89 #define i_back          i_chain[1]
90
91 /* flags */
92 #define IN_ACCESS       0x0020          /* inode access time to be updated */
93
94 #define VTOI(vp) ((struct iso_node *)(vp)->v_data)
95 #define ITOV(ip) ((ip)->i_vnode)
96
97 #ifdef _KERNEL
98
99 #ifdef MALLOC_DECLARE
100 MALLOC_DECLARE(M_ISOFSMNT);
101 MALLOC_DECLARE(M_ISOFSNODE);
102 #endif
103
104 struct buf;
105 struct vop_bmap_args;
106 struct vop_old_lookup_args;
107 struct vop_inactive_args;
108 struct vop_reclaim_args;
109
110 /*
111  * Prototypes for ISOFS vnode operations
112  */
113 int cd9660_lookup (struct vop_old_lookup_args *);
114 int cd9660_inactive (struct vop_inactive_args *);
115 int cd9660_reclaim (struct vop_reclaim_args *);
116 int cd9660_bmap (struct vop_bmap_args *);
117 int cd9660_blkatoff (struct vnode *vp, off_t offset, char **res, struct buf **bpp);
118
119 void cd9660_defattr (struct iso_directory_record *,
120                         struct iso_node *, struct buf *, enum ISO_FTYPE);
121 void cd9660_deftstamp (struct iso_directory_record *,
122                         struct iso_node *, struct buf *, enum ISO_FTYPE);
123 struct vnode *cd9660_ihashget (dev_t, ino_t);
124 int cd9660_ihashins (struct iso_node *);
125 int cd9660_tstamp_conv7 (u_char *, struct timespec *, enum ISO_FTYPE);
126 int cd9660_tstamp_conv17 (u_char *, struct timespec *);
127
128 #endif /* _KERNEL */