ext2 large_file
Brian Bergstrand
freebsd at classicalguitar.net
Sun Oct 30 17:09:58 PST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I ported the FreeBSD driver to Mac OS X / Darwin a few years ago and
added large file support in the process. Here's the patch, as you can
see it's a rather simple patch (as long as the in core i_size member
is 64bit which I think is true for FreeBSD):
I doubt this patch will apply cleanly as my tree has diverged from
FreeBSD in a non-compatible way quite a while ago -- but it should
give you a start:
The first part of the patch (@@ -98,7 +128,9 @@) is to ext2_ei2i()
and the second part (@@ -182,6 +214,31 @@) is to ext2_i2ei()
$ cvs diff -r 1.6 -r 1.7 ext2_inode_cnv.c
Index: ext2_inode_cnv.c
===================================================================
RCS file: /cvsroot/ext2fsx/src/gnu/ext2fs/ext2_inode_cnv.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
- --- ext2_inode_cnv.c 3 May 2003 23:54:39 -0000 1.6
+++ ext2_inode_cnv.c 9 Jul 2003 23:09:24 -0000 1.7
@@ -98,7 +128,9 @@
ip->i_uid |= le16_to_cpu(ei->i_uid_high) << 16;
ip->i_gid |= le16_to_cpu(ei->i_gid_high) << 16;
/*}*/
- - /* XXX use memcpy */
+ if (S_ISREG(ip->i_mode))
+ ip->i_size |= ((u_int64_t)le32_to_cpu(ei->i_size_high)) << 32;
+ /* TBD: Otherwise, setup the dir acl */
#if BYTE_ORDER == BIG_ENDIAN
/* We don't want to swap the block addr's for a short symlink
because
@@ -182,6 +214,31 @@
raw_inode->i_uid_high = 0;
raw_inode->i_gid_high = 0;
}*/
+ if (S_ISREG(ip->i_mode)) {
+ ei->i_size_high = cpu_to_le32(ip->i_size >> 32);
+ if (ip->i_size > 0x7fffffffULL) {
+ struct ext2_sb_info *sb = ip->i_e2fs;
+ if (!EXT2_HAS_RO_COMPAT_FEATURE(sb,
+ EXT2_FEATURE_RO_COMPAT_LARGE_FILE) ||
+ EXT2_SB(sb)->s_es->s_rev_level == cpu_to_le32
(EXT2_GOOD_OLD_REV)) {
+ /* First large file, add the flag to the superblock. */
+ lock_super (VFSTOEXT2(ip->i_vnode->v_mount)->um_devvp);
+
+ if (EXT2_SB(sb)->s_es->s_rev_level == cpu_to_le32
(EXT2_GOOD_OLD_REV)) {
+ log(LOG_WARNING,
+ "ext2: updating to rev %d because of new feature
flag, "
+ "running e2fsck is recommended", EXT2_DYNAMIC_REV);
+ sb->s_es->s_first_ino = cpu_to_le32
(EXT2_GOOD_OLD_FIRST_INO);
+ sb->s_es->s_inode_size = cpu_to_le16
(EXT2_GOOD_OLD_INODE_SIZE);
+ sb->s_es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV);
+ }
+
+ EXT2_SET_RO_COMPAT_FEATURE(sb,
EXT2_FEATURE_RO_COMPAT_LARGE_FILE);
+ sb->s_dirt = 1;
+ unlock_super (VFSTOEXT2(ip->i_vnode->v_mount)->um_devvp);
+ }
+ }
+ }
On Oct 30, 2005, at 11:37 AM, Ivan Voras wrote:
> I recently tried to use ext2 on FreeBSD but have decided not to
> when I saw that the support for large files is missing (and went
> with msdosfs instead).
>
> Now I accidentaly noticed that large_file support is present in
> latest NetBSD (and maybe OpenBSD). Is anyone interested in porting
> the support to FreeBSD? :)
>
Brian Bergstrand
<http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
iD8DBQFDZW7jedHYW7bHtqIRAtbIAKC4WIm+F/vruqRDWCfTLQ9XDrqNigCfdJO/
263t1QPoOgfSuz7LWwYEiAQ=
=gxC7
-----END PGP SIGNATURE-----
More information about the freebsd-fs
mailing list