[PATCH 02/12] cmsfs: header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
---
 fs/cmsfs/cmsfs.h      |  260 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/magic.h |    1 +
 2 files changed, 261 insertions(+), 0 deletions(-)
 create mode 100644 fs/cmsfs/cmsfs.h

diff --git a/fs/cmsfs/cmsfs.h b/fs/cmsfs/cmsfs.h
new file mode 100644
index 0000000..ab69e32
--- /dev/null
+++ b/fs/cmsfs/cmsfs.h
@@ -0,0 +1,260 @@
+#ifndef _CMSFS_H
+#define _CMSFS_H
+/*
+ * CMSFS
+ *
+ *  (C) 2008  Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
+ *
+ * Based on cmsfs from 2.4.12-ac6:
+ *
+ *  (C) 2001  Rick Troth <rtroth@xxxxxxx>
+ *  (C) 2001  BMC Software, Inc., Houston, Texas, USA
+ *
+ */
+
+/******************/
+/* FIXME: remove */
+extern __u8 _ascebc[256];   /* ASCII -> EBCDIC conversion table */
+extern __u8 _ebcasc[256];   /* EBCDIC -> ASCII conversion table */
+
+static inline void ebc_trans(__u8 *table, __u8 *addr, int len)
+{
+	for(; len; len--)
+		addr[len-1] = table[addr[len-1]];
+}
+
+#define EBC2ASC(addr,len) ebc_trans(_ebcasc, (addr), (len))
+#define ASC2EBC(addr,len) ebc_trans(_ascebc, (addr), (len))
+/******************/
+
+#define	CMSFS_FIRST_INO		8
+#define	CMSFS_DIRECTOR_INO	CMSFS_FIRST_INO
+#define	CMSFS_ALLOCMAP_INO	(CMSFS_DIRECTOR_INO + 1)
+
+/* filename (up to 8) + period + filetype (up to 8) */
+#define CMSFS_NAME_LEN		17
+
+/* Record format */
+enum recfm {
+	RECFM_FIXED = 0xc6, /* EBCDIC 'F' */
+	RECFM_VAR   = 0xe5, /* EBCDIC 'V' */
+};
+
+/*
+ * private data structs
+ */
+struct cmsfs_inode_info {
+	struct inode	vfs_inode;    /* Linux VFS inode */
+
+	enum recfm	recfm;
+	u32		lrecl;
+	u32		origin;       /* "base one" File Origin Pointer (FOP) */
+				      /* "base zero" offset is derived from FOP */
+	u32		blocks;       /* blocks in first-level */
+				      /* If there is only one level, then
+				         this is the total number of blocks */
+	u32		items;        /* number of records in this file */
+	u32		level;        /* level of indirection */
+	u32		psize;        /* size of indir pointers */
+
+	time_t		ctime;        /* computed UNIX time from CMS timestamp */
+};
+
+struct cmsfs_sb_info {
+	char    volid[7];       /* volume label (volume serial number) */
+	long	blksz;          /* statfs f_bsize block size of this volume */
+	int     origin;         /* "base one" Directory Origin Pointer (DOP) */
+	                        /* "base zero" offset is derived from DOP */
+	int     ncyls;          /* number of cylinders used by filesystem */
+	int     mcyls;          /* number of cylinders on the disk */
+				/* CMS has a concept of "recomp" where
+				   cylinders beyond the filesystem may be
+				   used by other things, like a boot loader. */
+	long	blocks;         /* statfs f_blocks: total number of blocks
+				   in the filesystem */
+	long    bkused;		/* blocks used (per ADT) */
+	int     fstsz;          /* size of each directory entry (of each FST) */
+	int     fstct;          /* number of FSTs (FST count) per block */
+	time_t  ctime;          /* time when this filesystem was created */
+	int     resoff;         /* reserved offset */
+	                        /* CMS has a concept of a "reserved disk"
+	                           where one file occupies the entire disk.
+	                           Additionally,  that file is referenced by this
+	                           so that the filesystem (directory) mechanism
+	                           can be bypassed. */
+	long    files;          /* statfs f_files: extracted from directory
+				   FST "items" */
+};
+
+/*
+ * Function prototypes
+ */
+extern int cmsfs_read_block(struct super_block *sb, void *buf, int block,
+			    unsigned blocksize);
+extern struct inode *cmsfs_iget(struct super_block *sb, unsigned long ino);
+extern void munge_name(__u8 *name, char *outname);
+extern ssize_t cmsfs_getxattr(struct dentry *dentry, const char *name,
+			      void *value, size_t size);
+extern int cmsfs_setxattr(struct dentry *dentry, const char *name,
+			  const void *value, size_t size, int flags);
+extern int cmsfs_removexattr(struct dentry *dentry, const char *name);
+extern ssize_t cmsfs_listxattr(struct dentry *dentry, char *list, size_t size);
+
+/*
+ * Static inlines
+ */
+static inline struct cmsfs_sb_info *CMSFS_SB(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline struct cmsfs_inode_info *CMSFS_I(struct inode *inode)
+{
+	return container_of(inode, struct cmsfs_inode_info, vfs_inode);
+}
+
+static inline int hex2int(__u8 c)
+{
+	return ((c >> 4) * 10) + (c & 0xf);
+}
+
+extern struct file_operations cmsfs_file_ops;
+extern struct address_space_operations cmsfs_aops;
+
+/*
+ * On disk structures
+ */
+
+/*
+ * File Status Table (FST)
+ *
+ * This information is based on VM/ESA 2.4.0.
+ * Last updated on 12 Aug 1999 at 11:21:05 EDT.
+ * Copyright IBM Corporation, 1990, 1999
+ * http://www.vm.ibm.com/pubs/cmsdacb/FSTD.HTML
+ *
+ *
+ *     +-------------------------------------------------------+
+ *   0 |                       FSTFNAME                        |
+ *     +-------------------------------------------------------+
+ *   8 |                       FSTFTYPE                        |
+ *     +-------------+-------------+-------------+-------------+
+ *  10 |  FSTDATEW   |  FSTTIMEW   |  FSTWRPNT   |  FSTRDPNT   |
+ *     +-------------+-------------+-------------+------+------+
+ *  18 |  FSTFMODE   |  FSTRECCT   |  FSTFCLPT   |:RECFM|:FLAGS|
+ *     +-------------+-------------+-------------+------+------+
+ *  20 |         FSTLRECL          |  FSTBLKCT   |  FSTYEARW   |
+ *     +---------------------------+-------------+-------------+
+ *  28 |          FSTFOP           |         FSTADBC           |
+ *     +---------------------------+------+------+-------------+
+ *  30 |          FSTAIC           |:NLVL |:PTRSZ|   (036)-    |
+ *     +---------------------------+------+------+-------------+
+ *  38 |        -FSTADATI          |:REALM|:FLAG2|/////////////|
+ *     +---------------------------+------+------+-------------+
+ *  40
+ *
+ */
+struct CMSFSFST {
+	__u8    FSTFNAME[8];       /* filename */
+	__u8    FSTFTYPE[8];       /* filetype */
+	__u8    FSTDATEW[2];       /* DATE LAST WRITTEN - MMDD */
+	__u8    FSTTIMEW[2];       /* TIME LAST WRITTEN - HHMM */
+	__be16  FSTWRPNT;          /* WRITE POINTER - ITEM NUMBER */
+	__be16  FSTRDPNT;          /* READ POINTER - ITEM NUMBER */
+	__u8    FSTFMODE[2];       /* FILE MODE - LETTER AND NUMBER */
+	__be16  FSTRECCT;          /* NUMBER OF LOGICAL RECORDS */
+	__be16  FSTFCLPT;          /* FIRST CHAIN LINK POINTER */
+	__u8    FSTRECFM;          /* F*1 - RECORD FORMAT - F OR V */
+#define FSTDFIX        0xC6 /* Fixed record format (EBCDIC 'F') */
+#define FSTDVAR        0xE5 /* Variable record format (EBCDIC 'V') */
+	__u8    FSTFLAGS;          /* F*2 - FST FLAG BYTE */
+#define FSTRWDSK       0x80 /* READ/WRITE DISK */
+#define FSTRODSK       0x00 /* READ/ONLY DISK */
+#define FSTDSFS        0x10 /* Shared File FST */
+#define FSTXRDSK       0x40 /* EXTENSION OF R/O DISK */
+#define FSTXWDSK       0xC0 /* EXTENSION OF R/W DISK */
+#define FSTEPL         0x20 /* EXTENDED PLIST */
+#define FSTDIA         0x40 /* ITEM AVAILABLE */
+#define FSTDRA         0x01 /* PREVIOUS RECORD NULL */
+#define FSTCNTRY       0x08 /* Century for date last written (0=19, 1=20),\\
+			       corresponds to FSTYEARW, FSTADATI. */
+#define FSTACTRD       0x04 /* ACTIVE FOR READING */
+#define FSTACTWR       0x02 /* ACTIVE FOR WRITING */
+#define FSTACTPT       0x01 /* ACTIVE FROM A POINT */
+#define FSTFILEA       0x07 /* THE FILE IS ACTIVE */
+	__be32  FSTLRECL;          /* LOGICAL RECORD LENGTH */
+	__be16  FSTBLKCT;          /* NUMBER OF 800 BYTE BLOCKS */
+	__be16  FSTYEARW;          /* YEAR LAST WRITTEN */
+	__be32  FSTFOP;            /* ALT. FILE ORIGIN POINTER */
+	__be32  FSTADBC;           /* ALT. NUMBER OF DATA BLOCKS */
+	__be32  FSTAIC;            /* ALT. ITEM COUNT */
+	__u8    FSTNLVL;           /* NUMBER OF POINTER BLOCK LEVELS */
+	__u8    FSTPTRSZ;          /* LENGTH OF A POINTER ELEMENT */
+	__u8    FSTADATI[6];       /* ALT. DATE/TIME(YY MM DD HH MM SS) */
+	__u8    FSTREALM;          /* Real filemode */
+	__u8    FSTFLAG2;          /* F*3 - FST FLAG BYTE 2 FSTFLAG2 */
+#define FSTPIPEU       0x10 /* Reserved for CMS PIPELINES usage */
+	__u8    reserved[2];
+};
+
+/*
+ * Active Disk Table (ADT) volume label
+ *
+ * This information is based on VM/ESA 2.4.0.
+ * Last updated on 12 Aug 1999 at 11:17:01 EDT.
+ * Copyright IBM Corporation, 1990, 1999
+ * http://www.vm.ibm.com/pubs/cmsdacb/ADTSECT.HTML
+ *
+ *
+ * The volume portion of ADT beings at offset 0x90 into the actual ADT
+ *
+ *     +---------------------------+---------------------------+
+ *  90 |         ADTIDENT          |          ADTID-           |
+ *     +-------------+-------------+---------------------------+
+ *  98 |   -(094)    |   ADTVER    |         ADTDBSIZ          |
+ *     +-------------+-------------+---------------------------+
+ *  A0 |          ADTDOP           |          ADTCYL           |
+ *     +---------------------------+---------------------------+
+ *  A8 |         ADTMCYL           |          ADTNUM           |
+ *     +---------------------------+---------------------------+
+ *  B0 |         ADTUSED           |         ADTFSTSZ          |
+ *     +---------------------------+---------------------------+
+ *  B8 |         ADTNFST           |        ADTDCRED-          |
+ *     +-------------+------+------+---------------------------+
+ *  C0 |   -(0BC)    |:FLGL |//////|         ADTOFFST          |
+ *     +-------------+------+------+---------------------------+
+ *  C8 |         ADTAMNB           |         ADTAMND           |
+ *     +---------------------------+---------------------------+
+ *  D0 |         ADTAMUP           |         ADTOFCNT          |
+ *     +---------------------------+---------------------------+
+ *  D8 |                       ADTSFNAM                        |
+ *     +-------------------------------------------------------+
+ *  E0
+ *
+ */
+struct CMSFSADT {
+	__be32  ADTIDENT;       /* VOL START / LABEL IDENTIFIER */
+	__u8    ADTID[6];       /* VOL START / VOL IDENTIFIER */
+	__u8    ADTVER[2];      /* VERSION LEVEL */
+	__be32  ADTDBSIZ;       /* DISK BLOCK SIZE */
+	__be32  ADTDOP;         /* DISK ORIGIN POINTER */
+	__be32  ADTCYL;         /* NUM OF FORMATTED CYL ON DISK */
+	__be32  ADTMCYL;        /* MAX NUM FORMATTED CYL ON DISK */
+	__be32  ADTNUM;         /* Number of Blocks on disk */
+	__be32  ADTUSED;        /* Number of Blocks used */
+	__be32  ADTFSTSZ;       /* SIZE OF FST */
+	__be32  ADTNFST;        /* NUMBER OF FST'S PER BLOCK */
+	__u8    ADTDCRED[6];    /* DISK CREATION DATE (YYMMDDHHMMSS) */
+	__u8    ADTFLGL;        /* LABEL FLAG BYTE (ADTFLGL) */
+#define ADTCNTRY        0x01 /* Century for disk creation date (0=19, 1=20),\\
+			      * corresponds to ADTDCRED. */
+	__u8    reserved[1];
+	__be32  ADTOFFST;       /* DISK OFFSET WHEN RESERVED */
+	__be32  ADTAMNB;        /* ALLOC MAP BLOCK WITH NEXT HOLE */
+	__be32  ADTAMND;        /* DISP INTO HBLK DATA OF NEXT HOLE */
+	__be32  ADTAMUP;        /* DISP INTO USER PART OF ALLOC MAP */
+	__be32  ADTOFCNT;       /* Count of SFS open files for this ADT */
+	__u8    ADTSFNAM[8];    /* NAME OF SHARED SEGMENT */
+};
+
+#endif
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 1fa0c2c..b41cc0a 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -5,6 +5,7 @@
 #define AFFS_SUPER_MAGIC	0xadff
 #define AFS_SUPER_MAGIC                0x5346414F
 #define AUTOFS_SUPER_MAGIC	0x0187
+#define CMSFS_SUPER_MAGIC	0xC3D4E2F1	/* 'CMS1' in EBCDIC */
 #define CODA_SUPER_MAGIC	0x73757245
 #define EFS_SUPER_MAGIC		0x414A53
 #define EXT2_SUPER_MAGIC	0xEF53
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux