[syslinux:elflink] xfs: Initial skeleton for XFS filesystem support
syslinux-bot for Paulo Alcantara
pcacjr at zytor.com
Tue Nov 27 12:57:04 PST 2012
Commit-ID: 28682155af7e9ec498c7d2f71962d51f48d56f28
Gitweb: http://www.syslinux.org/commit/28682155af7e9ec498c7d2f71962d51f48d56f28
Author: Paulo Alcantara <pcacjr at zytor.com>
AuthorDate: Fri, 8 Jun 2012 23:27:35 -0300
Committer: Paulo Alcantara <pcacjr at zytor.com>
CommitDate: Sat, 21 Jul 2012 01:21:45 -0300
xfs: Initial skeleton for XFS filesystem support
And another filesystem driver for Syslinux. Heh :-)
This patch *only* prints out a sample message on the screen when it
finds an active partition formated as a XFS filesystem. If this really
happens, then the XFS filesystem support in the EXTLINUX installer is
working nicely and it's time to write the driver.
Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>
---
core/fs/xfs/xfs.c | 66 +++++++++++++++++
{extlinux => core/fs/xfs}/xfs_fs.h | 0
{extlinux => core/fs/xfs}/xfs_sb.h | 132 +++++++++++++++++-----------------
{extlinux => core/fs/xfs}/xfs_types.h | 0
core/ldlinux.asm | 2 +
5 files changed, 134 insertions(+), 66 deletions(-)
diff --git a/core/fs/xfs/xfs.c b/core/fs/xfs/xfs.c
new file mode 100644
index 0000000..80969ff
--- /dev/null
+++ b/core/fs/xfs/xfs.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012 Paulo Alcantara <pcacjr at zytor.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dprintf.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/dirent.h>
+#include <cache.h>
+#include <core.h>
+#include <disk.h>
+#include <fs.h>
+#include <ilog2.h>
+#include <klibc/compiler.h>
+#include <ctype.h>
+
+#include "codepage.h"
+#include "xfs_types.h"
+#include "xfs_sb.h"
+
+static int xfs_fs_init(struct fs_info *fs)
+{
+ struct disk *disk = fs->fs_dev->disk;
+ xfs_sb_t sb;
+ int retval;
+
+ /* Read XFS superblock (LBA 0) */
+ retval = disk->rdwr_sectors(disk, &sb, 0, 1, 0);
+ if (!retval)
+ return -1;
+
+ if (sb.sb_magicnum == *(uint32_t *)XFS_SB_MAGIC)
+ printf("Cool! It's a XFS filesystem! :-)\n");
+
+ /* Nothing to do for now... */
+
+ return -1;
+}
+
+const struct fs_ops xfs_fs_ops = {
+ .fs_name = "ntfs",
+ .fs_flags = FS_USEMEM | FS_THISIND,
+ .fs_init = xfs_fs_init,
+ .searchdir = NULL,
+ .getfssec = NULL,
+ .load_config = NULL,
+ .close_file = NULL,
+ .mangle_name = NULL,
+ .readdir = NULL,
+ .iget_root = NULL,
+ .iget = NULL,
+ .next_extent = NULL,
+};
diff --git a/extlinux/xfs_fs.h b/core/fs/xfs/xfs_fs.h
similarity index 100%
copy from extlinux/xfs_fs.h
copy to core/fs/xfs/xfs_fs.h
diff --git a/extlinux/xfs_sb.h b/core/fs/xfs/xfs_sb.h
similarity index 80%
copy from extlinux/xfs_sb.h
copy to core/fs/xfs/xfs_sb.h
index 8f72d6a..2290e6a 100644
--- a/extlinux/xfs_sb.h
+++ b/core/fs/xfs/xfs_sb.h
@@ -20,12 +20,13 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef XFS_SB_H_
-#define XFS_SB_H__
+#define XFS_SB_H_
#include <stddef.h>
#include <sys/types.h>
-#include <uuid/uuid.h>
+
+typedef unsigned char uuid_t[16];
/*
* Super block
@@ -106,71 +107,70 @@ struct xfs_mount;
* Must be padded to 64 bit alignment.
*/
typedef struct xfs_sb {
- uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
- uint32_t sb_blocksize; /* logical block size, bytes */
- xfs_drfsbno_t sb_dblocks; /* number of data blocks */
- xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
- xfs_drtbno_t sb_rextents; /* number of realtime extents */
- uuid_t sb_uuid; /* file system unique id */
- xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
- xfs_ino_t sb_rootino; /* root inode number */
- xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
- xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
- xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
- xfs_agblock_t sb_agblocks; /* size of an allocation group */
- xfs_agnumber_t sb_agcount; /* number of allocation groups */
- xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
- xfs_extlen_t sb_logblocks; /* number of log blocks */
- uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
- uint16_t sb_sectsize; /* volume sector size, bytes */
- uint16_t sb_inodesize; /* inode size, bytes */
- uint16_t sb_inopblock; /* inodes per block */
- char sb_fname[12]; /* file system name */
- uint8_t sb_blocklog; /* log2 of sb_blocksize */
- uint8_t sb_sectlog; /* log2 of sb_sectsize */
- uint8_t sb_inodelog; /* log2 of sb_inodesize */
- uint8_t sb_inopblog; /* log2 of sb_inopblock */
- uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
- uint8_t sb_rextslog; /* log2 of sb_rextents */
- uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
- uint8_t sb_imax_pct; /* max % of fs for inode space */
+ uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
+ uint32_t sb_blocksize; /* logical block size, bytes */
+ xfs_drfsbno_t sb_dblocks; /* number of data blocks */
+ xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
+ xfs_drtbno_t sb_rextents; /* number of realtime extents */
+ uuid_t sb_uuid; /* file system unique id */
+ xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
+ xfs_ino_t sb_rootino; /* root inode number */
+ xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
+ xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
+ xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
+ xfs_agblock_t sb_agblocks; /* size of an allocation group */
+ xfs_agnumber_t sb_agcount; /* number of allocation groups */
+ xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
+ xfs_extlen_t sb_logblocks; /* number of log blocks */
+ uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
+ uint16_t sb_sectsize; /* volume sector size, bytes */
+ uint16_t sb_inodesize; /* inode size, bytes */
+ uint16_t sb_inopblock; /* inodes per block */
+ char sb_fname[12]; /* file system name */
+ uint8_t sb_blocklog; /* log2 of sb_blocksize */
+ uint8_t sb_sectlog; /* log2 of sb_sectsize */
+ uint8_t sb_inodelog; /* log2 of sb_inodesize */
+ uint8_t sb_inopblog; /* log2 of sb_inopblock */
+ uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
+ uint8_t sb_rextslog; /* log2 of sb_rextents */
+ uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
+ uint8_t sb_imax_pct; /* max % of fs for inode space */
/* statistics */
- /*
- * These fields must remain contiguous. If you really
- * want to change their layout, make sure you fix the
- * code in xfs_trans_apply_sb_deltas().
- */
- uint64_t sb_icount; /* allocated inodes */
- uint64_t sb_ifree; /* free inodes */
- uint64_t sb_fdblocks; /* free data blocks */
- uint64_t sb_frextents; /* free realtime extents */
- /*
- * End contiguous fields.
- */
- xfs_ino_t sb_uquotino; /* user quota inode */
- xfs_ino_t sb_gquotino; /* group quota inode */
- uint16_t sb_qflags; /* quota flags */
- uint8_t sb_flags; /* misc. flags */
- uint8_t sb_shared_vn; /* shared version number */
- xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
- uint32_t sb_unit; /* stripe or raid unit */
- uint32_t sb_width; /* stripe or raid width */
- uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
- uint8_t sb_logsectlog; /* log2 of the log sector size */
- uint16_t sb_logsectsize; /* sector size for the log, bytes */
- uint32_t sb_logsunit; /* stripe unit size for the log */
- uint32_t sb_features2; /* additional feature bits */
-
- /*
- * bad features2 field as a result of failing to pad the sb
- * structure to 64 bits. Some machines will be using this field
- * for features2 bits. Easiest just to mark it bad and not use
- * it for anything else.
- */
- uint32_t sb_bad_features2;
-
- /* must be padded to 64 bit alignment */
-} xfs_sb_t;
+ /*
+ * These fields must remain contiguous. If you really
+ * want to change their layout, make sure you fix the
+ * code in xfs_trans_apply_sb_deltas().
+ */
+ uint64_t sb_icount; /* allocated inodes */
+ uint64_t sb_ifree; /* free inodes */
+ uint64_t sb_fdblocks; /* free data blocks */
+ uint64_t sb_frextents; /* free realtime extents */
+ /*
+ * End contiguous fields.
+ */
+ xfs_ino_t sb_uquotino; /* user quota inode */
+ xfs_ino_t sb_gquotino; /* group quota inode */
+ uint16_t sb_qflags; /* quota flags */
+ uint8_t sb_flags; /* misc. flags */
+ uint8_t sb_shared_vn; /* shared version number */
+ xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
+ uint32_t sb_unit; /* stripe or raid unit */
+ uint32_t sb_width; /* stripe or raid width */
+ uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
+ uint8_t sb_logsectlog; /* log2 of the log sector size */
+ uint16_t sb_logsectsize; /* sector size for the log, bytes */
+ uint32_t sb_logsunit; /* stripe unit size for the log */
+ uint32_t sb_features2; /* additional feature bits */
+
+ /*
+ * bad features2 field as a result of failing to pad the sb
+ * structure to 64 bits. Some machines will be using this field
+ * for features2 bits. Easiest just to mark it bad and not use
+ * it for anything else.
+ */
+ uint32_t sb_bad_features2;
+ uint8_t pad[304]; /* must be padded to a sector boundary */
+} __attribute__((__packed__)) xfs_sb_t;
/*
* Sequence number values for the fields.
diff --git a/extlinux/xfs_types.h b/core/fs/xfs/xfs_types.h
similarity index 100%
copy from extlinux/xfs_types.h
copy to core/fs/xfs/xfs_types.h
diff --git a/core/ldlinux.asm b/core/ldlinux.asm
index a2f859d..a1f96b7 100644
--- a/core/ldlinux.asm
+++ b/core/ldlinux.asm
@@ -39,6 +39,8 @@ ROOT_FS_OPS:
dd ext2_fs_ops
extern ntfs_fs_ops
dd ntfs_fs_ops
+ extern xfs_fs_ops
+ dd xfs_fs_ops
extern btrfs_fs_ops
dd btrfs_fs_ops
dd 0
More information about the Syslinux-commits
mailing list