Home | History | Annotate | Line # | Download | only in adosfs
adosfs.h revision 1.5.4.1
      1  1.5.4.1      yamt /*	$NetBSD: adosfs.h,v 1.5.4.1 2006/06/21 15:09:23 yamt Exp $	*/
      2      1.1  jdolecek 
      3      1.1  jdolecek /*
      4      1.1  jdolecek  * Copyright (c) 1994 Christian E. Hopps
      5      1.1  jdolecek  * Copyright (c) 1996 Matthias Scheler
      6      1.1  jdolecek  * All rights reserved.
      7      1.1  jdolecek  *
      8      1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
      9      1.1  jdolecek  * modification, are permitted provided that the following conditions
     10      1.1  jdolecek  * are met:
     11      1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     12      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     13      1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     14      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     15      1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     16      1.1  jdolecek  * 3. All advertising materials mentioning features or use of this software
     17      1.1  jdolecek  *    must display the following acknowledgement:
     18      1.1  jdolecek  *      This product includes software developed by Christian E. Hopps.
     19      1.1  jdolecek  * 4. The name of the author may not be used to endorse or promote products
     20      1.1  jdolecek  *    derived from this software without specific prior written permission
     21      1.1  jdolecek  *
     22      1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23      1.1  jdolecek  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24      1.1  jdolecek  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25      1.1  jdolecek  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26      1.1  jdolecek  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27      1.1  jdolecek  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28      1.1  jdolecek  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29      1.1  jdolecek  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30      1.1  jdolecek  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31      1.1  jdolecek  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32      1.1  jdolecek  */
     33      1.1  jdolecek 
     34  1.5.4.1      yamt #ifndef _ADOSFS_ADOSFS_H_
     35  1.5.4.1      yamt #define  _ADOSFS_ADOSFS_H_
     36      1.1  jdolecek /*
     37      1.1  jdolecek  * Arguments to mount amigados filesystems.
     38      1.1  jdolecek  */
     39      1.1  jdolecek struct adosfs_args {
     40      1.1  jdolecek 	char	*fspec;		/* blocks special holding the fs to mount */
     41  1.5.4.1      yamt 	struct	export_args30 _pad1; /* compat with old userland tools */
     42      1.1  jdolecek 	uid_t	uid;		/* uid that owns adosfs files */
     43      1.1  jdolecek 	gid_t	gid;		/* gid that owns adosfs files */
     44      1.1  jdolecek 	mode_t	mask;		/* mask to be applied for adosfs perms */
     45      1.1  jdolecek };
     46      1.1  jdolecek 
     47      1.1  jdolecek #ifdef _KERNEL
     48      1.2   thorpej #include <sys/mallocvar.h>
     49      1.1  jdolecek #include <miscfs/genfs/genfs_node.h>
     50      1.2   thorpej 
     51      1.2   thorpej MALLOC_DECLARE(M_ANODE);
     52      1.1  jdolecek 
     53      1.1  jdolecek /*
     54      1.1  jdolecek  * Amigados datestamp. (from 1/1/1978 00:00:00 local)
     55      1.1  jdolecek  */
     56      1.1  jdolecek struct datestamp {
     57      1.1  jdolecek 	u_int32_t days;
     58      1.1  jdolecek 	u_int32_t mins;
     59      1.1  jdolecek 	u_int32_t ticks;	/* 20000 * (ticks % 50) = useconds */
     60      1.1  jdolecek 				/* ticks / 50 = seconds */
     61      1.1  jdolecek };
     62      1.1  jdolecek 
     63      1.1  jdolecek enum anode_type { AROOT, ADIR, AFILE, ALDIR, ALFILE, ASLINK };
     64      1.1  jdolecek 
     65      1.4  jdolecek /* Maximum file/directory name */
     66      1.4  jdolecek #define ADMAXNAMELEN		30
     67      1.4  jdolecek 
     68      1.5     perry /*
     69      1.1  jdolecek  * similar to inode's, we use to represent:
     70      1.1  jdolecek  * the root dir, reg dirs, reg files and extension blocks
     71      1.1  jdolecek  * note the ``tab'' is a hash table for r/d, and a data block
     72      1.1  jdolecek  * table for f/e. it is always ANODETABSZ(ap) bytes in size.
     73      1.1  jdolecek  */
     74      1.1  jdolecek struct anode {
     75      1.1  jdolecek 	struct genfs_node gnode;
     76      1.1  jdolecek 	LIST_ENTRY(anode) link;
     77      1.1  jdolecek 	enum anode_type type;
     78      1.4  jdolecek 	char name[ADMAXNAMELEN+1];	/* (r/d/f) name for object */
     79      1.1  jdolecek 	struct datestamp mtimev;	/* (r) volume modified */
     80      1.1  jdolecek 	struct datestamp created;	/* (r) volume created */
     81      1.1  jdolecek 	struct datestamp mtime;	/* (r/d/f) last modified */
     82      1.1  jdolecek 	struct adosfsmount *amp;	/* owner file system */
     83      1.1  jdolecek 	struct vnode *vp;	/* owner vnode */
     84      1.1  jdolecek 	u_long fsize;		/* (f) size of file in bytes */
     85      1.1  jdolecek 	u_long block;		/* block num */
     86      1.1  jdolecek 	u_long pblock;		/* (d/f/e) parent block */
     87      1.1  jdolecek 	u_long hashf;		/* (d/f) hash forward */
     88      1.1  jdolecek 	u_long extb;		/* (f/e) extension block number */
     89      1.1  jdolecek 	u_long linkto;		/* (hd/hf) header this link points at */
     90      1.1  jdolecek 	u_long linknext;	/* (d/f/hd/hf) next link (or head) in chain */
     91      1.1  jdolecek 	u_long lastlindblk;	/* (f/hf) last logical indirect block */
     92      1.1  jdolecek 	u_long lastindblk;	/* (f/hf) last indirect block read */
     93      1.1  jdolecek 	u_long *tab;		/* (r/d) hash table */
     94      1.1  jdolecek 	int *tabi;		/* (r/d) table info */
     95      1.1  jdolecek 	int ntabent;		/* (r/d) number of entries in table */
     96      1.1  jdolecek 	int nwords;		/* size of blocks in long words */
     97      1.1  jdolecek 	int adprot;		/* (d/f) amigados protection bits */
     98      1.1  jdolecek 	uid_t  uid;		/* (d/f) uid of directory/file */
     99      1.1  jdolecek 	gid_t  gid;		/* (d/f) gid of directory/file */
    100      1.5     perry 	int flags;		/* misc flags */
    101      1.1  jdolecek 	char *slinkto;		/* name of file or dir */
    102      1.1  jdolecek };
    103      1.1  jdolecek #define VTOA(vp)		((struct anode *)(vp)->v_data)
    104      1.1  jdolecek #define ATOV(ap)		((ap)->vp)
    105      1.1  jdolecek #define ANODETABSZ(ap)		(((ap)->nwords - 56) * sizeof(long))
    106      1.1  jdolecek #define ANODETABENT(ap)		((ap)->nwords - 56)
    107      1.1  jdolecek #define ANODENDATBLKENT(ap)	((ap)->nwords - 56)
    108      1.1  jdolecek 
    109      1.1  jdolecek /*
    110      1.5     perry  * mount data
    111      1.1  jdolecek  */
    112      1.1  jdolecek #define ANODEHASHSZ (512)
    113      1.1  jdolecek 
    114      1.1  jdolecek struct adosfsmount {
    115      1.1  jdolecek 	LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ];
    116      1.1  jdolecek 	struct mount *mp;	/* owner mount */
    117      1.1  jdolecek 	u_int32_t dostype;	/* type of volume */
    118      1.1  jdolecek 	u_long rootb;		/* root block number */
    119      1.1  jdolecek 	u_long secsperblk;	/* sectors per block */
    120      1.1  jdolecek 	u_long bsize;		/* size of blocks */
    121      1.1  jdolecek 	u_long nwords;		/* size of blocks in long words */
    122      1.1  jdolecek 	u_long dbsize;		/* data bytes per block */
    123      1.1  jdolecek 	uid_t  uid;		/* uid of mounting user */
    124      1.1  jdolecek 	gid_t  gid;		/* gid of mounting user */
    125      1.1  jdolecek 	u_long mask;		/* mode mask */
    126      1.1  jdolecek 	struct vnode *devvp;	/* blk device mounted on */
    127      1.1  jdolecek 	struct vnode *rootvp;	/* out root vnode */
    128      1.1  jdolecek 	u_long *bitmap;		/* allocation bitmap */
    129      1.1  jdolecek 	u_long numblks;		/* number of usable blocks */
    130      1.1  jdolecek 	u_long freeblks;	/* number of free blocks */
    131      1.1  jdolecek };
    132      1.1  jdolecek 
    133      1.1  jdolecek #define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data)
    134      1.1  jdolecek 
    135      1.1  jdolecek #define IS_FFS(amp)	((amp)->dostype & 1)
    136      1.1  jdolecek #define IS_INTER(amp)	(((amp)->dostype & 7) > 1)
    137      1.1  jdolecek 
    138      1.1  jdolecek /*
    139      1.1  jdolecek  * AmigaDOS block stuff.
    140      1.1  jdolecek  */
    141      1.1  jdolecek #define BBOFF		(0)
    142      1.1  jdolecek 
    143      1.1  jdolecek #define BPT_SHORT	((u_int32_t)2)
    144      1.1  jdolecek #define BPT_DATA	((u_int32_t)8)
    145      1.1  jdolecek #define BPT_LIST	((u_int32_t)16)
    146      1.1  jdolecek 
    147      1.1  jdolecek #define BST_RDIR	((u_int32_t)1)
    148      1.1  jdolecek #define BST_UDIR	((u_int32_t)2)
    149      1.1  jdolecek #define BST_SLINK	((u_int32_t)3)
    150      1.1  jdolecek #define BST_LDIR	((u_int32_t)4)
    151      1.1  jdolecek #define BST_FILE	((u_int32_t)-3)
    152      1.1  jdolecek #define BST_LFILE	((u_int32_t)-4)
    153      1.1  jdolecek 
    154      1.1  jdolecek #define	OFS_DATA_OFFSET	(24)
    155      1.1  jdolecek 
    156      1.1  jdolecek extern struct pool adosfs_node_pool;
    157      1.1  jdolecek 
    158      1.1  jdolecek /*
    159      1.1  jdolecek  * utility protos
    160      1.1  jdolecek  */
    161      1.1  jdolecek #if BYTE_ORDER != BIG_ENDIAN
    162      1.1  jdolecek u_int32_t adoswordn __P((struct buf *, int));
    163      1.1  jdolecek #else
    164      1.1  jdolecek #define adoswordn(bp,wn) (*((u_int32_t *)(bp)->b_data + (wn)))
    165      1.1  jdolecek #endif
    166      1.1  jdolecek 
    167      1.1  jdolecek u_int32_t adoscksum __P((struct buf *, int));
    168      1.1  jdolecek int adoscaseequ __P((const u_char *, const u_char *, int, int));
    169      1.1  jdolecek int adoshash __P((const u_char *, int, int, int));
    170      1.1  jdolecek int adunixprot __P((int));
    171      1.1  jdolecek int adosfs_getblktype __P((struct adosfsmount *, struct buf *));
    172      1.1  jdolecek 
    173      1.1  jdolecek struct vnode *adosfs_ahashget __P((struct mount *, ino_t));
    174      1.1  jdolecek void adosfs_ainshash __P((struct adosfsmount *, struct anode *));
    175      1.1  jdolecek void adosfs_aremhash __P((struct anode *));
    176      1.1  jdolecek 
    177      1.1  jdolecek int adosfs_lookup __P((void *));
    178      1.1  jdolecek 
    179      1.1  jdolecek extern int (**adosfs_vnodeop_p) __P((void *));
    180      1.3    atatat 
    181      1.3    atatat #ifdef SYSCTL_SETUP_PROTO
    182      1.3    atatat SYSCTL_SETUP_PROTO(sysctl_vfs_adosfs_setup);
    183      1.3    atatat #endif /* SYSCTL_SETUP_PROTO */
    184      1.1  jdolecek #endif /* _KERNEL */
    185  1.5.4.1      yamt #endif /* _ADOSFS_ADOSFS_H_ */
    186