[PATCH 09/12] cmsfs: misc helpers

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

 



Signed-off-by: Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
---
 fs/cmsfs/helpers.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)
 create mode 100644 fs/cmsfs/helpers.c

diff --git a/fs/cmsfs/helpers.c b/fs/cmsfs/helpers.c
new file mode 100644
index 0000000..93800b3
--- /dev/null
+++ b/fs/cmsfs/helpers.c
@@ -0,0 +1,78 @@
+/*
+ * 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
+ *
+ */
+
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+
+#include "cmsfs.h"
+
+void munge_name(__u8 *name, char *outname)
+{
+	__u8 *p = name;
+	char *orig_outname = outname;
+
+	if (!name)
+		return;
+
+	/*
+	 * NOTE:
+	 *   '\x40' is a space in EBCDIC
+	 *   '\x4b' is a period in EBCDIC
+	 */
+
+	/* file name */
+	while(*p != '\x40' && (p - name < 8))
+		*outname++ = *p++;
+
+	*outname++ = '\x4b';
+
+	p = name+8;
+
+	while(*p != '\x40' && (p - name < 16))
+		*outname++ = *p++;
+
+	*outname = '\0';
+
+	EBC2ASC(orig_outname, 17);
+}
+
+/**
+ * cmsfs_read_block - read a single disk block
+ * @sb:		superblock to read from
+ * @buf:	buffer to fill
+ * @block:	block number to read
+ * @blocksize:	blocksize to use
+ */
+int cmsfs_read_block(struct super_block *sb, void *buf, int block,
+		     unsigned blocksize)
+{
+	struct buffer_head * bh;
+
+	/*  for the moment,  we only deal with physical blocks  */
+	BUG_ON(blocksize != sb->s_blocksize);
+
+	/* We could maybe handle that case by breaking-up this call into
+	   multiple bread() calls, but that'll be a later driver rev.  */
+
+	/* Call the system-level __bread() */
+	bh = __bread(sb->s_bdev, block, blocksize);
+	if (!bh) {
+		printk(KERN_WARNING "cmsfs: system bread() failed.\n");
+		return -EIO;
+	}
+
+	/* copy the data part,  then release the VFS buffer */
+	memmove(buf, bh->b_data, blocksize);
+	brelse(bh);
+
+	return blocksize;
+}
-- 
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