From: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Subject: [PATCH 02/12] cmsfs: header file
Date: Sun, 21 Sep 2008 21:29:18 -0400 [thread overview]
Message-ID: <1222046968-3364-3-git-send-email-jeffpc@josefsipek.net> (raw)
In-Reply-To: <1222046968-3364-1-git-send-email-jeffpc@josefsipek.net>
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
---
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@josefsipek.net>
+ *
+ * Based on cmsfs from 2.4.12-ac6:
+ *
+ * (C) 2001 Rick Troth <rtroth@bmc.com>
+ * (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
next prev parent reply other threads:[~2008-09-22 1:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-22 1:29 [RFC PATCH] CMS minidisk filesystem support Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 01/12] cmsfs: Documentation Josef 'Jeff' Sipek
2008-09-22 1:29 ` Josef 'Jeff' Sipek [this message]
2008-09-22 1:29 ` [PATCH 03/12] cmsfs: EBCDIC translation table Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 04/12] cmsfs: block mapping code Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 05/12] cmsfs: file operations Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 06/12] cmsfs: inode operations Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 07/12] cmsfs: super block operations Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 08/12] cmsfs: export extra file attributes via xattr Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 09/12] cmsfs: misc helpers Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 10/12] MAINTAINERS: cmsfs entry Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 11/12] cmsfs: Kconfig entry Josef 'Jeff' Sipek
2008-09-22 1:29 ` [PATCH 12/12] cmsfs: Makefile Josef 'Jeff' Sipek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1222046968-3364-3-git-send-email-jeffpc@josefsipek.net \
--to=jeffpc@josefsipek.net \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).