Added jfs - Christoph Hellwig
Added sysv - Tim Launchbury
Added udf - Bryce Nesbitt
- Added gfs/gfs2 - Eric Sandeen
+ Added gfs/gfs2, btrfs - Eric Sandeen
*/
/*
struct adfs_super_block adfssb;
struct sysv_super_block svsb;
struct gfs2_sb gfs2sb;
+ struct btrfs_super_block btrfssb;
struct stat statbuf;
/* opening and reading an arbitrary unknown path can have
}
}
+ if (!type) {
+ /* block 64 */
+ if (lseek(fd, BTRFS_SUPER_INFO_OFFSET, SEEK_SET) != BTRFS_SUPER_INFO_OFFSET
+ || read(fd, (char *) &btrfssb, sizeof(btrfssb)) != sizeof(btrfssb))
+ goto io_error;
+ if (!strncmp((char *)(btrfssb.magic), BTRFS_MAGIC,
+ sizeof(btrfssb.magic))) {
+ type = "btrfs";
+ }
+ }
+
if (!type) {
/* perhaps the user tries to mount the swap space
on a new disk; warn her before she does mkfs on it */
#define gfsformat(s) assemble4be(s.sb_fs_format)
#define gfsmultiformat(s) assemble4be(s.sb_multihost_format)
+/* btrfs constants */
+#define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
+
+/* 32 bytes in various csum fields */
+#define BTRFS_CSUM_SIZE 32
+
+#define BTRFS_FSID_SIZE 16
+
+#define BTRFS_MAGIC "_BHRfS_M"
+
+/*
+ * the super block basically lists the main trees of the FS
+ * it currently lacks any block count etc etc
+ */
+struct btrfs_super_block {
+ char csum[BTRFS_CSUM_SIZE];
+ /* the first 3 fields must match struct btrfs_header */
+ char fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
+ char bytenr[8]; /* this block number */
+ char flags[8];
+
+ /* allowed to be different from the btrfs_header from here own down */
+ char magic[8];
+ /* more follows but this is all our libdisk cares about*/
+} __attribute__ ((__packed__));
+
static inline int
assemble2le(char *p) {
return (p[0] | (p[1] << 8));