From 4e246704eab31407ac15be9ab206c6f929507cf0 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 9 Dec 2000 14:39:16 +0000 Subject: [PATCH] ChangeLog, ext2fs.h, mkjournal.c: ext2fs.h, mkjournal.c (ext2fs_add_journal_fs, ext2fs_add_journal_device): Add a new argument to the APIs of these function, which is a flags word. This is used to allow the creation of a V1 superblock for those folks who are using ext3 0.3b in production. Note, the user-land interface for getting at this flag won't be documented, as the V1 superblock is deprecated. --- lib/ext2fs/ChangeLog | 8 ++++++++ lib/ext2fs/ext2fs.h | 13 ++++++++++--- lib/ext2fs/mkjournal.c | 15 +++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 44f4fef..e28a5d6 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,13 @@ 2000-12-09 + * ext2fs.h, mkjournal.c (ext2fs_add_journal_fs, + ext2fs_add_journal_device): Add a new argument to the APIs + of these function, which is a flags word. This is used to + allow the creation of a V1 superblock for those folks who + are using ext3 0.3b in production. Note, the user-land + interface for getting at this flag won't be documented, as + the V1 superblock is deprecated. + * mkjournal.c (init_journal_superblock): Sync Stephen's changes which creates a V2 superblock instead of a V1 superblock. diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index e579386..3c428dc 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -160,7 +160,6 @@ typedef struct ext2_file *ext2_file_t; /* * Flags for the ext2_filsys structure */ - #define EXT2_FLAG_RW 0x01 #define EXT2_FLAG_CHANGED 0x02 #define EXT2_FLAG_DIRTY 0x04 @@ -179,6 +178,13 @@ typedef struct ext2_file *ext2_file_t; */ #define EXT2_NEW_INODE_FL 0x80000000 +/* + * Flags for mkjournal + * + * EXT2_MKJOURNAL_V1_SUPER Make a (deprecated) V1 journal superblock + */ +#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 + struct struct_ext2_filsys { errcode_t magic; io_channel io; @@ -811,8 +817,9 @@ extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, /* mkjournal.c */ extern errcode_t ext2fs_add_journal_device(ext2_filsys fs, char *device, - blk_t size); -extern errcode_t ext2fs_add_journal_fs(ext2_filsys fs, blk_t size); + blk_t size, int flags); +extern errcode_t ext2fs_add_journal_fs(ext2_filsys fs, blk_t size, + int flags); /* openfs.c */ extern errcode_t ext2fs_open(const char *name, int flags, int superblock, diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index fcb01e3..5246f64 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -39,12 +39,15 @@ #include "jfs_user.h" static void init_journal_superblock(journal_superblock_t *jsb, - __u32 blocksize, __u32 size) + __u32 blocksize, __u32 size, int flags) { memset (jsb, 0, sizeof(*jsb)); jsb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER); - jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2); + if (flags & EXT2_MKJOURNAL_V1_SUPER) + jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V1); + else + jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2); jsb->s_blocksize = htonl(blocksize); jsb->s_maxlen = htonl(size); jsb->s_first = htonl(1); @@ -55,7 +58,7 @@ static void init_journal_superblock(journal_superblock_t *jsb, * This function adds a journal device to a filesystem */ errcode_t ext2fs_add_journal_device(ext2_filsys fs, char *device, - blk_t size) + blk_t size, int flags) { journal_superblock_t jsb; struct stat st; @@ -80,7 +83,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, char *device, else if (size > dev_size) return EINVAL; /* Requested size bigger than device */ - init_journal_superblock(&jsb, fs->blocksize, size); + init_journal_superblock(&jsb, fs->blocksize, size, flags); /* Create a block buffer */ buf = malloc(fs->blocksize); @@ -192,7 +195,7 @@ static int mkjournal_proc(ext2_filsys fs, /* * This function adds a journal inode to a filesystem */ -errcode_t ext2fs_add_journal_fs(ext2_filsys fs, blk_t size) +errcode_t ext2fs_add_journal_fs(ext2_filsys fs, blk_t size, int flags) { journal_superblock_t jsb; errcode_t retval; @@ -200,7 +203,7 @@ errcode_t ext2fs_add_journal_fs(ext2_filsys fs, blk_t size) struct mkjournal_struct es; char *buf; - init_journal_superblock(&jsb, fs->blocksize, size); + init_journal_superblock(&jsb, fs->blocksize, size, flags); if ((retval = ext2fs_read_bitmaps(fs))) return retval; -- 1.8.3.1