mirror of
https://github.com/t2linux/kernel.git
synced 2026-04-30 13:48:59 -07:00
fs: Remove ext3 filesystem driver
The functionality of ext3 is fully supported by ext4 driver. Major distributions (SUSE, RedHat) already use ext4 driver to handle ext3 filesystems for quite some time. There is some ugliness in mm resulting from jbd cleaning buffers in a dirty page without cleaning page dirty bit and also support for buffer bouncing in the block layer when stable pages are required is there only because of jbd. So let's remove the ext3 driver. This saves us some 28k lines of duplicated code. Acked-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
@@ -360,8 +360,8 @@ and are copied into the filesystem. If a transaction is incomplete at
|
||||
the time of the crash, then there is no guarantee of consistency for
|
||||
the blocks in that transaction so they are discarded (which means any
|
||||
filesystem changes they represent are also lost).
|
||||
Check Documentation/filesystems/ext3.txt if you want to read more about
|
||||
ext3 and journaling.
|
||||
Check Documentation/filesystems/ext4.txt if you want to read more about
|
||||
ext4 and journaling.
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
@@ -6,210 +6,7 @@ Ext3 was originally released in September 1999. Written by Stephen Tweedie
|
||||
for the 2.2 branch, and ported to 2.4 kernels by Peter Braam, Andreas Dilger,
|
||||
Andrew Morton, Alexander Viro, Ted Ts'o and Stephen Tweedie.
|
||||
|
||||
Ext3 is the ext2 filesystem enhanced with journalling capabilities.
|
||||
Ext3 is the ext2 filesystem enhanced with journalling capabilities. The
|
||||
filesystem is a subset of ext4 filesystem so use ext4 driver for accessing
|
||||
ext3 filesystems.
|
||||
|
||||
Options
|
||||
=======
|
||||
|
||||
When mounting an ext3 filesystem, the following option are accepted:
|
||||
(*) == default
|
||||
|
||||
ro Mount filesystem read only. Note that ext3 will replay
|
||||
the journal (and thus write to the partition) even when
|
||||
mounted "read only". Mount options "ro,noload" can be
|
||||
used to prevent writes to the filesystem.
|
||||
|
||||
journal=update Update the ext3 file system's journal to the current
|
||||
format.
|
||||
|
||||
journal=inum When a journal already exists, this option is ignored.
|
||||
Otherwise, it specifies the number of the inode which
|
||||
will represent the ext3 file system's journal file.
|
||||
|
||||
journal_path=path
|
||||
journal_dev=devnum When the external journal device's major/minor numbers
|
||||
have changed, these options allow the user to specify
|
||||
the new journal location. The journal device is
|
||||
identified through either its new major/minor numbers
|
||||
encoded in devnum, or via a path to the device.
|
||||
|
||||
norecovery Don't load the journal on mounting. Note that this forces
|
||||
noload mount of inconsistent filesystem, which can lead to
|
||||
various problems.
|
||||
|
||||
data=journal All data are committed into the journal prior to being
|
||||
written into the main file system.
|
||||
|
||||
data=ordered (*) All data are forced directly out to the main file
|
||||
system prior to its metadata being committed to the
|
||||
journal.
|
||||
|
||||
data=writeback Data ordering is not preserved, data may be written
|
||||
into the main file system after its metadata has been
|
||||
committed to the journal.
|
||||
|
||||
commit=nrsec (*) Ext3 can be told to sync all its data and metadata
|
||||
every 'nrsec' seconds. The default value is 5 seconds.
|
||||
This means that if you lose your power, you will lose
|
||||
as much as the latest 5 seconds of work (your
|
||||
filesystem will not be damaged though, thanks to the
|
||||
journaling). This default value (or any low value)
|
||||
will hurt performance, but it's good for data-safety.
|
||||
Setting it to 0 will have the same effect as leaving
|
||||
it at the default (5 seconds).
|
||||
Setting it to very large values will improve
|
||||
performance.
|
||||
|
||||
barrier=<0|1(*)> This enables/disables the use of write barriers in
|
||||
barrier (*) the jbd code. barrier=0 disables, barrier=1 enables.
|
||||
nobarrier This also requires an IO stack which can support
|
||||
barriers, and if jbd gets an error on a barrier
|
||||
write, it will disable again with a warning.
|
||||
Write barriers enforce proper on-disk ordering
|
||||
of journal commits, making volatile disk write caches
|
||||
safe to use, at some performance penalty. If
|
||||
your disks are battery-backed in one way or another,
|
||||
disabling barriers may safely improve performance.
|
||||
The mount options "barrier" and "nobarrier" can
|
||||
also be used to enable or disable barriers, for
|
||||
consistency with other ext3 mount options.
|
||||
|
||||
user_xattr Enables Extended User Attributes. Additionally, you
|
||||
need to have extended attribute support enabled in the
|
||||
kernel configuration (CONFIG_EXT3_FS_XATTR). See the
|
||||
attr(5) manual page and http://acl.bestbits.at/ to
|
||||
learn more about extended attributes.
|
||||
|
||||
nouser_xattr Disables Extended User Attributes.
|
||||
|
||||
acl Enables POSIX Access Control Lists support.
|
||||
Additionally, you need to have ACL support enabled in
|
||||
the kernel configuration (CONFIG_EXT3_FS_POSIX_ACL).
|
||||
See the acl(5) manual page and http://acl.bestbits.at/
|
||||
for more information.
|
||||
|
||||
noacl This option disables POSIX Access Control List
|
||||
support.
|
||||
|
||||
reservation
|
||||
|
||||
noreservation
|
||||
|
||||
bsddf (*) Make 'df' act like BSD.
|
||||
minixdf Make 'df' act like Minix.
|
||||
|
||||
check=none Don't do extra checking of bitmaps on mount.
|
||||
nocheck
|
||||
|
||||
debug Extra debugging information is sent to syslog.
|
||||
|
||||
errors=remount-ro Remount the filesystem read-only on an error.
|
||||
errors=continue Keep going on a filesystem error.
|
||||
errors=panic Panic and halt the machine if an error occurs.
|
||||
(These mount options override the errors behavior
|
||||
specified in the superblock, which can be
|
||||
configured using tune2fs.)
|
||||
|
||||
data_err=ignore(*) Just print an error message if an error occurs
|
||||
in a file data buffer in ordered mode.
|
||||
data_err=abort Abort the journal if an error occurs in a file
|
||||
data buffer in ordered mode.
|
||||
|
||||
grpid Give objects the same group ID as their creator.
|
||||
bsdgroups
|
||||
|
||||
nogrpid (*) New objects have the group ID of their creator.
|
||||
sysvgroups
|
||||
|
||||
resgid=n The group ID which may use the reserved blocks.
|
||||
|
||||
resuid=n The user ID which may use the reserved blocks.
|
||||
|
||||
sb=n Use alternate superblock at this location.
|
||||
|
||||
quota These options are ignored by the filesystem. They
|
||||
noquota are used only by quota tools to recognize volumes
|
||||
grpquota where quota should be turned on. See documentation
|
||||
usrquota in the quota-tools package for more details
|
||||
(http://sourceforge.net/projects/linuxquota).
|
||||
|
||||
jqfmt=<quota type> These options tell filesystem details about quota
|
||||
usrjquota=<file> so that quota information can be properly updated
|
||||
grpjquota=<file> during journal replay. They replace the above
|
||||
quota options. See documentation in the quota-tools
|
||||
package for more details
|
||||
(http://sourceforge.net/projects/linuxquota).
|
||||
|
||||
Specification
|
||||
=============
|
||||
Ext3 shares all disk implementation with the ext2 filesystem, and adds
|
||||
transactions capabilities to ext2. Journaling is done by the Journaling Block
|
||||
Device layer.
|
||||
|
||||
Journaling Block Device layer
|
||||
-----------------------------
|
||||
The Journaling Block Device layer (JBD) isn't ext3 specific. It was designed
|
||||
to add journaling capabilities to a block device. The ext3 filesystem code
|
||||
will inform the JBD of modifications it is performing (called a transaction).
|
||||
The journal supports the transactions start and stop, and in case of a crash,
|
||||
the journal can replay the transactions to quickly put the partition back into
|
||||
a consistent state.
|
||||
|
||||
Handles represent a single atomic update to a filesystem. JBD can handle an
|
||||
external journal on a block device.
|
||||
|
||||
Data Mode
|
||||
---------
|
||||
There are 3 different data modes:
|
||||
|
||||
* writeback mode
|
||||
In data=writeback mode, ext3 does not journal data at all. This mode provides
|
||||
a similar level of journaling as that of XFS, JFS, and ReiserFS in its default
|
||||
mode - metadata journaling. A crash+recovery can cause incorrect data to
|
||||
appear in files which were written shortly before the crash. This mode will
|
||||
typically provide the best ext3 performance.
|
||||
|
||||
* ordered mode
|
||||
In data=ordered mode, ext3 only officially journals metadata, but it logically
|
||||
groups metadata and data blocks into a single unit called a transaction. When
|
||||
it's time to write the new metadata out to disk, the associated data blocks
|
||||
are written first. In general, this mode performs slightly slower than
|
||||
writeback but significantly faster than journal mode.
|
||||
|
||||
* journal mode
|
||||
data=journal mode provides full data and metadata journaling. All new data is
|
||||
written to the journal first, and then to its final location.
|
||||
In the event of a crash, the journal can be replayed, bringing both data and
|
||||
metadata into a consistent state. This mode is the slowest except when data
|
||||
needs to be read from and written to disk at the same time where it
|
||||
outperforms all other modes.
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
Ext2 partitions can be easily convert to ext3, with `tune2fs -j <dev>`.
|
||||
Ext3 is fully compatible with Ext2. Ext3 partitions can easily be mounted as
|
||||
Ext2.
|
||||
|
||||
|
||||
External Tools
|
||||
==============
|
||||
See manual pages to learn more.
|
||||
|
||||
tune2fs: create a ext3 journal on a ext2 partition with the -j flag.
|
||||
mke2fs: create a ext3 partition with the -j flag.
|
||||
debugfs: ext2 and ext3 file system debugger.
|
||||
ext2online: online (mounted) ext2 and ext3 filesystem resizer
|
||||
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
kernel source: <file:fs/ext3/>
|
||||
<file:fs/jbd/>
|
||||
|
||||
programs: http://e2fsprogs.sourceforge.net/
|
||||
http://ext2resize.sourceforge.net
|
||||
|
||||
useful links: http://www.ibm.com/developerworks/library/l-fs7/index.html
|
||||
http://www.ibm.com/developerworks/library/l-fs8/index.html
|
||||
|
||||
@@ -769,7 +769,7 @@ struct address_space_operations {
|
||||
to stall to allow flushers a chance to complete some IO. Ordinarily
|
||||
it can use PageDirty and PageWriteback but some filesystems have
|
||||
more complex state (unstable pages in NFS prevent reclaim) or
|
||||
do not set those flags due to locking problems (jbd). This callback
|
||||
do not set those flags due to locking problems. This callback
|
||||
allows a filesystem to indicate to the VM if a page should be
|
||||
treated as dirty or writeback for the purposes of stalling.
|
||||
|
||||
|
||||
+1
-17
@@ -4059,15 +4059,6 @@ F: Documentation/filesystems/ext2.txt
|
||||
F: fs/ext2/
|
||||
F: include/linux/ext2*
|
||||
|
||||
EXT3 FILE SYSTEM
|
||||
M: Jan Kara <jack@suse.com>
|
||||
M: Andrew Morton <akpm@linux-foundation.org>
|
||||
M: Andreas Dilger <adilger.kernel@dilger.ca>
|
||||
L: linux-ext4@vger.kernel.org
|
||||
S: Maintained
|
||||
F: Documentation/filesystems/ext3.txt
|
||||
F: fs/ext3/
|
||||
|
||||
EXT4 FILE SYSTEM
|
||||
M: "Theodore Ts'o" <tytso@mit.edu>
|
||||
M: Andreas Dilger <adilger.kernel@dilger.ca>
|
||||
@@ -5751,16 +5742,9 @@ S: Maintained
|
||||
F: fs/jffs2/
|
||||
F: include/uapi/linux/jffs2.h
|
||||
|
||||
JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
|
||||
M: Andrew Morton <akpm@linux-foundation.org>
|
||||
M: Jan Kara <jack@suse.com>
|
||||
L: linux-ext4@vger.kernel.org
|
||||
S: Maintained
|
||||
F: fs/jbd/
|
||||
F: include/linux/jbd.h
|
||||
|
||||
JOURNALLING LAYER FOR BLOCK DEVICES (JBD2)
|
||||
M: "Theodore Ts'o" <tytso@mit.edu>
|
||||
M: Jan Kara <jack@suse.com>
|
||||
L: linux-ext4@vger.kernel.org
|
||||
S: Maintained
|
||||
F: fs/jbd2/
|
||||
|
||||
+1
-4
@@ -11,18 +11,15 @@ config DCACHE_WORD_ACCESS
|
||||
if BLOCK
|
||||
|
||||
source "fs/ext2/Kconfig"
|
||||
source "fs/ext3/Kconfig"
|
||||
source "fs/ext4/Kconfig"
|
||||
source "fs/jbd/Kconfig"
|
||||
source "fs/jbd2/Kconfig"
|
||||
|
||||
config FS_MBCACHE
|
||||
# Meta block cache for Extended Attributes (ext2/ext3/ext4)
|
||||
tristate
|
||||
default y if EXT2_FS=y && EXT2_FS_XATTR
|
||||
default y if EXT3_FS=y && EXT3_FS_XATTR
|
||||
default y if EXT4_FS=y
|
||||
default m if EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4_FS
|
||||
default m if EXT2_FS_XATTR || EXT4_FS
|
||||
|
||||
source "fs/reiserfs/Kconfig"
|
||||
source "fs/jfs/Kconfig"
|
||||
|
||||
@@ -62,12 +62,10 @@ obj-$(CONFIG_DLM) += dlm/
|
||||
# Do not add any filesystems before this line
|
||||
obj-$(CONFIG_FSCACHE) += fscache/
|
||||
obj-$(CONFIG_REISERFS_FS) += reiserfs/
|
||||
obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3
|
||||
obj-$(CONFIG_EXT2_FS) += ext2/
|
||||
# We place ext4 after ext2 so plain ext2 root fs's are mounted using ext2
|
||||
# unless explicitly requested by rootfstype
|
||||
obj-$(CONFIG_EXT4_FS) += ext4/
|
||||
obj-$(CONFIG_JBD) += jbd/
|
||||
obj-$(CONFIG_JBD2) += jbd2/
|
||||
obj-$(CONFIG_CRAMFS) += cramfs/
|
||||
obj-$(CONFIG_SQUASHFS) += squashfs/
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
config EXT3_FS
|
||||
tristate "Ext3 journalling file system support"
|
||||
select JBD
|
||||
help
|
||||
This is the journalling version of the Second extended file system
|
||||
(often called ext3), the de facto standard Linux file system
|
||||
(method to organize files on a storage device) for hard disks.
|
||||
|
||||
The journalling code included in this driver means you do not have
|
||||
to run e2fsck (file system checker) on your file systems after a
|
||||
crash. The journal keeps track of any changes that were being made
|
||||
at the time the system crashed, and can ensure that your file system
|
||||
is consistent without the need for a lengthy check.
|
||||
|
||||
Other than adding the journal to the file system, the on-disk format
|
||||
of ext3 is identical to ext2. It is possible to freely switch
|
||||
between using the ext3 driver and the ext2 driver, as long as the
|
||||
file system has been cleanly unmounted, or e2fsck is run on the file
|
||||
system.
|
||||
|
||||
To add a journal on an existing ext2 file system or change the
|
||||
behavior of ext3 file systems, you can use the tune2fs utility ("man
|
||||
tune2fs"). To modify attributes of files and directories on ext3
|
||||
file systems, use chattr ("man chattr"). You need to be using
|
||||
e2fsprogs version 1.20 or later in order to create ext3 journals
|
||||
(available at <http://sourceforge.net/projects/e2fsprogs/>).
|
||||
|
||||
To compile this file system support as a module, choose M here: the
|
||||
module will be called ext3.
|
||||
|
||||
config EXT3_DEFAULTS_TO_ORDERED
|
||||
bool "Default to 'data=ordered' in ext3"
|
||||
depends on EXT3_FS
|
||||
default y
|
||||
help
|
||||
The journal mode options for ext3 have different tradeoffs
|
||||
between when data is guaranteed to be on disk and
|
||||
performance. The use of "data=writeback" can cause
|
||||
unwritten data to appear in files after an system crash or
|
||||
power failure, which can be a security issue. However,
|
||||
"data=ordered" mode can also result in major performance
|
||||
problems, including seconds-long delays before an fsync()
|
||||
call returns. For details, see:
|
||||
|
||||
http://ext4.wiki.kernel.org/index.php/Ext3_data_mode_tradeoffs
|
||||
|
||||
If you have been historically happy with ext3's performance,
|
||||
data=ordered mode will be a safe choice and you should
|
||||
answer 'y' here. If you understand the reliability and data
|
||||
privacy issues of data=writeback and are willing to make
|
||||
that trade off, answer 'n'.
|
||||
|
||||
config EXT3_FS_XATTR
|
||||
bool "Ext3 extended attributes"
|
||||
depends on EXT3_FS
|
||||
default y
|
||||
help
|
||||
Extended attributes are name:value pairs associated with inodes by
|
||||
the kernel or by users (see the attr(5) manual page, or visit
|
||||
<http://acl.bestbits.at/> for details).
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
You need this for POSIX ACL support on ext3.
|
||||
|
||||
config EXT3_FS_POSIX_ACL
|
||||
bool "Ext3 POSIX Access Control Lists"
|
||||
depends on EXT3_FS_XATTR
|
||||
select FS_POSIX_ACL
|
||||
help
|
||||
Posix Access Control Lists (ACLs) support permissions for users and
|
||||
groups beyond the owner/group/world scheme.
|
||||
|
||||
To learn more about Access Control Lists, visit the Posix ACLs for
|
||||
Linux website <http://acl.bestbits.at/>.
|
||||
|
||||
If you don't know what Access Control Lists are, say N
|
||||
|
||||
config EXT3_FS_SECURITY
|
||||
bool "Ext3 Security Labels"
|
||||
depends on EXT3_FS_XATTR
|
||||
help
|
||||
Security labels support alternative access control models
|
||||
implemented by security modules like SELinux. This option
|
||||
enables an extended attribute handler for file security
|
||||
labels in the ext3 filesystem.
|
||||
|
||||
If you are not using a security module that requires using
|
||||
extended attributes for file security labels, say N.
|
||||
@@ -1,12 +0,0 @@
|
||||
#
|
||||
# Makefile for the linux ext3-filesystem routines.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_EXT3_FS) += ext3.o
|
||||
|
||||
ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
|
||||
ioctl.o namei.o super.o symlink.o hash.o resize.o ext3_jbd.o
|
||||
|
||||
ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
|
||||
ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
|
||||
ext3-$(CONFIG_EXT3_FS_SECURITY) += xattr_security.o
|
||||
-281
@@ -1,281 +0,0 @@
|
||||
/*
|
||||
* linux/fs/ext3/acl.c
|
||||
*
|
||||
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
|
||||
*/
|
||||
|
||||
#include "ext3.h"
|
||||
#include "xattr.h"
|
||||
#include "acl.h"
|
||||
|
||||
/*
|
||||
* Convert from filesystem to in-memory representation.
|
||||
*/
|
||||
static struct posix_acl *
|
||||
ext3_acl_from_disk(const void *value, size_t size)
|
||||
{
|
||||
const char *end = (char *)value + size;
|
||||
int n, count;
|
||||
struct posix_acl *acl;
|
||||
|
||||
if (!value)
|
||||
return NULL;
|
||||
if (size < sizeof(ext3_acl_header))
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (((ext3_acl_header *)value)->a_version !=
|
||||
cpu_to_le32(EXT3_ACL_VERSION))
|
||||
return ERR_PTR(-EINVAL);
|
||||
value = (char *)value + sizeof(ext3_acl_header);
|
||||
count = ext3_acl_count(size);
|
||||
if (count < 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (count == 0)
|
||||
return NULL;
|
||||
acl = posix_acl_alloc(count, GFP_NOFS);
|
||||
if (!acl)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
for (n=0; n < count; n++) {
|
||||
ext3_acl_entry *entry =
|
||||
(ext3_acl_entry *)value;
|
||||
if ((char *)value + sizeof(ext3_acl_entry_short) > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
|
||||
acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
|
||||
switch(acl->a_entries[n].e_tag) {
|
||||
case ACL_USER_OBJ:
|
||||
case ACL_GROUP_OBJ:
|
||||
case ACL_MASK:
|
||||
case ACL_OTHER:
|
||||
value = (char *)value +
|
||||
sizeof(ext3_acl_entry_short);
|
||||
break;
|
||||
|
||||
case ACL_USER:
|
||||
value = (char *)value + sizeof(ext3_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_uid =
|
||||
make_kuid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
value = (char *)value + sizeof(ext3_acl_entry);
|
||||
if ((char *)value > end)
|
||||
goto fail;
|
||||
acl->a_entries[n].e_gid =
|
||||
make_kgid(&init_user_ns,
|
||||
le32_to_cpu(entry->e_id));
|
||||
break;
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (value != end)
|
||||
goto fail;
|
||||
return acl;
|
||||
|
||||
fail:
|
||||
posix_acl_release(acl);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert from in-memory to filesystem representation.
|
||||
*/
|
||||
static void *
|
||||
ext3_acl_to_disk(const struct posix_acl *acl, size_t *size)
|
||||
{
|
||||
ext3_acl_header *ext_acl;
|
||||
char *e;
|
||||
size_t n;
|
||||
|
||||
*size = ext3_acl_size(acl->a_count);
|
||||
ext_acl = kmalloc(sizeof(ext3_acl_header) + acl->a_count *
|
||||
sizeof(ext3_acl_entry), GFP_NOFS);
|
||||
if (!ext_acl)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);
|
||||
e = (char *)ext_acl + sizeof(ext3_acl_header);
|
||||
for (n=0; n < acl->a_count; n++) {
|
||||
const struct posix_acl_entry *acl_e = &acl->a_entries[n];
|
||||
ext3_acl_entry *entry = (ext3_acl_entry *)e;
|
||||
entry->e_tag = cpu_to_le16(acl_e->e_tag);
|
||||
entry->e_perm = cpu_to_le16(acl_e->e_perm);
|
||||
switch(acl_e->e_tag) {
|
||||
case ACL_USER:
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kuid(&init_user_ns, acl_e->e_uid));
|
||||
e += sizeof(ext3_acl_entry);
|
||||
break;
|
||||
case ACL_GROUP:
|
||||
entry->e_id = cpu_to_le32(
|
||||
from_kgid(&init_user_ns, acl_e->e_gid));
|
||||
e += sizeof(ext3_acl_entry);
|
||||
break;
|
||||
|
||||
case ACL_USER_OBJ:
|
||||
case ACL_GROUP_OBJ:
|
||||
case ACL_MASK:
|
||||
case ACL_OTHER:
|
||||
e += sizeof(ext3_acl_entry_short);
|
||||
break;
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
return (char *)ext_acl;
|
||||
|
||||
fail:
|
||||
kfree(ext_acl);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inode operation get_posix_acl().
|
||||
*
|
||||
* inode->i_mutex: don't care
|
||||
*/
|
||||
struct posix_acl *
|
||||
ext3_get_acl(struct inode *inode, int type)
|
||||
{
|
||||
int name_index;
|
||||
char *value = NULL;
|
||||
struct posix_acl *acl;
|
||||
int retval;
|
||||
|
||||
switch (type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
|
||||
break;
|
||||
case ACL_TYPE_DEFAULT:
|
||||
name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
||||
retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
|
||||
if (retval > 0) {
|
||||
value = kmalloc(retval, GFP_NOFS);
|
||||
if (!value)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
retval = ext3_xattr_get(inode, name_index, "", value, retval);
|
||||
}
|
||||
if (retval > 0)
|
||||
acl = ext3_acl_from_disk(value, retval);
|
||||
else if (retval == -ENODATA || retval == -ENOSYS)
|
||||
acl = NULL;
|
||||
else
|
||||
acl = ERR_PTR(retval);
|
||||
kfree(value);
|
||||
|
||||
if (!IS_ERR(acl))
|
||||
set_cached_acl(inode, type, acl);
|
||||
|
||||
return acl;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the access or default ACL of an inode.
|
||||
*
|
||||
* inode->i_mutex: down unless called from ext3_new_inode
|
||||
*/
|
||||
static int
|
||||
__ext3_set_acl(handle_t *handle, struct inode *inode, int type,
|
||||
struct posix_acl *acl)
|
||||
{
|
||||
int name_index;
|
||||
void *value = NULL;
|
||||
size_t size = 0;
|
||||
int error;
|
||||
|
||||
switch(type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
|
||||
if (acl) {
|
||||
error = posix_acl_equiv_mode(acl, &inode->i_mode);
|
||||
if (error < 0)
|
||||
return error;
|
||||
else {
|
||||
inode->i_ctime = CURRENT_TIME_SEC;
|
||||
ext3_mark_inode_dirty(handle, inode);
|
||||
if (error == 0)
|
||||
acl = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ACL_TYPE_DEFAULT:
|
||||
name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
|
||||
if (!S_ISDIR(inode->i_mode))
|
||||
return acl ? -EACCES : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
if (acl) {
|
||||
value = ext3_acl_to_disk(acl, &size);
|
||||
if (IS_ERR(value))
|
||||
return (int)PTR_ERR(value);
|
||||
}
|
||||
|
||||
error = ext3_xattr_set_handle(handle, inode, name_index, "",
|
||||
value, size, 0);
|
||||
|
||||
kfree(value);
|
||||
|
||||
if (!error)
|
||||
set_cached_acl(inode, type, acl);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type)
|
||||
{
|
||||
handle_t *handle;
|
||||
int error, retries = 0;
|
||||
|
||||
retry:
|
||||
handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
|
||||
if (IS_ERR(handle))
|
||||
return PTR_ERR(handle);
|
||||
error = __ext3_set_acl(handle, inode, type, acl);
|
||||
ext3_journal_stop(handle);
|
||||
if (error == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
|
||||
goto retry;
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the ACLs of a new inode. Called from ext3_new_inode.
|
||||
*
|
||||
* dir->i_mutex: down
|
||||
* inode->i_mutex: up (access to inode is still exclusive)
|
||||
*/
|
||||
int
|
||||
ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||
{
|
||||
struct posix_acl *default_acl, *acl;
|
||||
int error;
|
||||
|
||||
error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (default_acl) {
|
||||
error = __ext3_set_acl(handle, inode, ACL_TYPE_DEFAULT,
|
||||
default_acl);
|
||||
posix_acl_release(default_acl);
|
||||
}
|
||||
if (acl) {
|
||||
if (!error)
|
||||
error = __ext3_set_acl(handle, inode, ACL_TYPE_ACCESS,
|
||||
acl);
|
||||
posix_acl_release(acl);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
File: fs/ext3/acl.h
|
||||
|
||||
(C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
|
||||
*/
|
||||
|
||||
#include <linux/posix_acl_xattr.h>
|
||||
|
||||
#define EXT3_ACL_VERSION 0x0001
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
__le32 e_id;
|
||||
} ext3_acl_entry;
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
} ext3_acl_entry_short;
|
||||
|
||||
typedef struct {
|
||||
__le32 a_version;
|
||||
} ext3_acl_header;
|
||||
|
||||
static inline size_t ext3_acl_size(int count)
|
||||
{
|
||||
if (count <= 4) {
|
||||
return sizeof(ext3_acl_header) +
|
||||
count * sizeof(ext3_acl_entry_short);
|
||||
} else {
|
||||
return sizeof(ext3_acl_header) +
|
||||
4 * sizeof(ext3_acl_entry_short) +
|
||||
(count - 4) * sizeof(ext3_acl_entry);
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ext3_acl_count(size_t size)
|
||||
{
|
||||
ssize_t s;
|
||||
size -= sizeof(ext3_acl_header);
|
||||
s = size - 4 * sizeof(ext3_acl_entry_short);
|
||||
if (s < 0) {
|
||||
if (size % sizeof(ext3_acl_entry_short))
|
||||
return -1;
|
||||
return size / sizeof(ext3_acl_entry_short);
|
||||
} else {
|
||||
if (s % sizeof(ext3_acl_entry))
|
||||
return -1;
|
||||
return s / sizeof(ext3_acl_entry) + 4;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXT3_FS_POSIX_ACL
|
||||
|
||||
/* acl.c */
|
||||
extern struct posix_acl *ext3_get_acl(struct inode *inode, int type);
|
||||
extern int ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type);
|
||||
extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
|
||||
|
||||
#else /* CONFIG_EXT3_FS_POSIX_ACL */
|
||||
#include <linux/sched.h>
|
||||
#define ext3_get_acl NULL
|
||||
#define ext3_set_acl NULL
|
||||
|
||||
static inline int
|
||||
ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_EXT3_FS_POSIX_ACL */
|
||||
|
||||
-2158
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* linux/fs/ext3/bitmap.c
|
||||
*
|
||||
* Copyright (C) 1992, 1993, 1994, 1995
|
||||
* Remy Card (card@masi.ibp.fr)
|
||||
* Laboratoire MASI - Institut Blaise Pascal
|
||||
* Universite Pierre et Marie Curie (Paris VI)
|
||||
*/
|
||||
|
||||
#include "ext3.h"
|
||||
|
||||
#ifdef EXT3FS_DEBUG
|
||||
|
||||
unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars)
|
||||
{
|
||||
return numchars * BITS_PER_BYTE - memweight(map->b_data, numchars);
|
||||
}
|
||||
|
||||
#endif /* EXT3FS_DEBUG */
|
||||
|
||||
-537
File diff suppressed because it is too large
Load Diff
-1332
File diff suppressed because it is too large
Load Diff
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Interface between ext3 and JBD
|
||||
*/
|
||||
|
||||
#include "ext3.h"
|
||||
|
||||
int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
|
||||
struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_get_undo_access(handle, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __ext3_journal_get_write_access(const char *where, handle_t *handle,
|
||||
struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_get_write_access(handle, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __ext3_journal_forget(const char *where, handle_t *handle,
|
||||
struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_forget(handle, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __ext3_journal_revoke(const char *where, handle_t *handle,
|
||||
unsigned long blocknr, struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_revoke(handle, blocknr, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __ext3_journal_get_create_access(const char *where,
|
||||
handle_t *handle, struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_get_create_access(handle, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
|
||||
int __ext3_journal_dirty_metadata(const char *where,
|
||||
handle_t *handle, struct buffer_head *bh)
|
||||
{
|
||||
int err = journal_dirty_metadata(handle, bh);
|
||||
if (err)
|
||||
ext3_journal_abort_handle(where, __func__, bh, handle,err);
|
||||
return err;
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* linux/fs/ext3/file.c
|
||||
*
|
||||
* Copyright (C) 1992, 1993, 1994, 1995
|
||||
* Remy Card (card@masi.ibp.fr)
|
||||
* Laboratoire MASI - Institut Blaise Pascal
|
||||
* Universite Pierre et Marie Curie (Paris VI)
|
||||
*
|
||||
* from
|
||||
*
|
||||
* linux/fs/minix/file.c
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*
|
||||
* ext3 fs regular file handling primitives
|
||||
*
|
||||
* 64-bit file support on 64-bit platforms by Jakub Jelinek
|
||||
* (jj@sunsite.ms.mff.cuni.cz)
|
||||
*/
|
||||
|
||||
#include <linux/quotaops.h>
|
||||
#include "ext3.h"
|
||||
#include "xattr.h"
|
||||
#include "acl.h"
|
||||
|
||||
/*
|
||||
* Called when an inode is released. Note that this is different
|
||||
* from ext3_file_open: open gets called at every open, but release
|
||||
* gets called only when /all/ the files are closed.
|
||||
*/
|
||||
static int ext3_release_file (struct inode * inode, struct file * filp)
|
||||
{
|
||||
if (ext3_test_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE)) {
|
||||
filemap_flush(inode->i_mapping);
|
||||
ext3_clear_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE);
|
||||
}
|
||||
/* if we are the last writer on the inode, drop the block reservation */
|
||||
if ((filp->f_mode & FMODE_WRITE) &&
|
||||
(atomic_read(&inode->i_writecount) == 1))
|
||||
{
|
||||
mutex_lock(&EXT3_I(inode)->truncate_mutex);
|
||||
ext3_discard_reservation(inode);
|
||||
mutex_unlock(&EXT3_I(inode)->truncate_mutex);
|
||||
}
|
||||
if (is_dx(inode) && filp->private_data)
|
||||
ext3_htree_free_dir_info(filp->private_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct file_operations ext3_file_operations = {
|
||||
.llseek = generic_file_llseek,
|
||||
.read_iter = generic_file_read_iter,
|
||||
.write_iter = generic_file_write_iter,
|
||||
.unlocked_ioctl = ext3_ioctl,
|
||||
#ifdef CONFIG_COMPAT
|
||||
.compat_ioctl = ext3_compat_ioctl,
|
||||
#endif
|
||||
.mmap = generic_file_mmap,
|
||||
.open = dquot_file_open,
|
||||
.release = ext3_release_file,
|
||||
.fsync = ext3_sync_file,
|
||||
.splice_read = generic_file_splice_read,
|
||||
.splice_write = iter_file_splice_write,
|
||||
};
|
||||
|
||||
const struct inode_operations ext3_file_inode_operations = {
|
||||
.setattr = ext3_setattr,
|
||||
#ifdef CONFIG_EXT3_FS_XATTR
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = ext3_listxattr,
|
||||
.removexattr = generic_removexattr,
|
||||
#endif
|
||||
.get_acl = ext3_get_acl,
|
||||
.set_acl = ext3_set_acl,
|
||||
.fiemap = ext3_fiemap,
|
||||
};
|
||||
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* linux/fs/ext3/fsync.c
|
||||
*
|
||||
* Copyright (C) 1993 Stephen Tweedie (sct@redhat.com)
|
||||
* from
|
||||
* Copyright (C) 1992 Remy Card (card@masi.ibp.fr)
|
||||
* Laboratoire MASI - Institut Blaise Pascal
|
||||
* Universite Pierre et Marie Curie (Paris VI)
|
||||
* from
|
||||
* linux/fs/minix/truncate.c Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*
|
||||
* ext3fs fsync primitive
|
||||
*
|
||||
* Big-endian to little-endian byte-swapping/bitmaps by
|
||||
* David S. Miller (davem@caip.rutgers.edu), 1995
|
||||
*
|
||||
* Removed unnecessary code duplication for little endian machines
|
||||
* and excessive __inline__s.
|
||||
* Andi Kleen, 1997
|
||||
*
|
||||
* Major simplications and cleanup - we only need to do the metadata, because
|
||||
* we can depend on generic_block_fdatasync() to sync the data blocks.
|
||||
*/
|
||||
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/writeback.h>
|
||||
#include "ext3.h"
|
||||
|
||||
/*
|
||||
* akpm: A new design for ext3_sync_file().
|
||||
*
|
||||
* This is only called from sys_fsync(), sys_fdatasync() and sys_msync().
|
||||
* There cannot be a transaction open by this task.
|
||||
* Another task could have dirtied this inode. Its data can be in any
|
||||
* state in the journalling system.
|
||||
*
|
||||
* What we do is just kick off a commit and wait on it. This will snapshot the
|
||||
* inode to disk.
|
||||
*/
|
||||
|
||||
int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
|
||||
{
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
struct ext3_inode_info *ei = EXT3_I(inode);
|
||||
journal_t *journal = EXT3_SB(inode->i_sb)->s_journal;
|
||||
int ret, needs_barrier = 0;
|
||||
tid_t commit_tid;
|
||||
|
||||
trace_ext3_sync_file_enter(file, datasync);
|
||||
|
||||
if (inode->i_sb->s_flags & MS_RDONLY) {
|
||||
/* Make sure that we read updated state */
|
||||
smp_rmb();
|
||||
if (EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ERROR_FS)
|
||||
return -EROFS;
|
||||
return 0;
|
||||
}
|
||||
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
J_ASSERT(ext3_journal_current_handle() == NULL);
|
||||
|
||||
/*
|
||||
* data=writeback,ordered:
|
||||
* The caller's filemap_fdatawrite()/wait will sync the data.
|
||||
* Metadata is in the journal, we wait for a proper transaction
|
||||
* to commit here.
|
||||
*
|
||||
* data=journal:
|
||||
* filemap_fdatawrite won't do anything (the buffers are clean).
|
||||
* ext3_force_commit will write the file data into the journal and
|
||||
* will wait on that.
|
||||
* filemap_fdatawait() will encounter a ton of newly-dirtied pages
|
||||
* (they were dirtied by commit). But that's OK - the blocks are
|
||||
* safe in-journal, which is all fsync() needs to ensure.
|
||||
*/
|
||||
if (ext3_should_journal_data(inode)) {
|
||||
ret = ext3_force_commit(inode->i_sb);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (datasync)
|
||||
commit_tid = atomic_read(&ei->i_datasync_tid);
|
||||
else
|
||||
commit_tid = atomic_read(&ei->i_sync_tid);
|
||||
|
||||
if (test_opt(inode->i_sb, BARRIER) &&
|
||||
!journal_trans_will_send_data_barrier(journal, commit_tid))
|
||||
needs_barrier = 1;
|
||||
log_start_commit(journal, commit_tid);
|
||||
ret = log_wait_commit(journal, commit_tid);
|
||||
|
||||
/*
|
||||
* In case we didn't commit a transaction, we have to flush
|
||||
* disk caches manually so that data really is on persistent
|
||||
* storage
|
||||
*/
|
||||
if (needs_barrier) {
|
||||
int err;
|
||||
|
||||
err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
|
||||
if (!ret)
|
||||
ret = err;
|
||||
}
|
||||
out:
|
||||
trace_ext3_sync_file_exit(inode, ret);
|
||||
return ret;
|
||||
}
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* linux/fs/ext3/hash.c
|
||||
*
|
||||
* Copyright (C) 2002 by Theodore Ts'o
|
||||
*
|
||||
* This file is released under the GPL v2.
|
||||
*
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
*/
|
||||
|
||||
#include "ext3.h"
|
||||
#include <linux/cryptohash.h>
|
||||
|
||||
#define DELTA 0x9E3779B9
|
||||
|
||||
static void TEA_transform(__u32 buf[4], __u32 const in[])
|
||||
{
|
||||
__u32 sum = 0;
|
||||
__u32 b0 = buf[0], b1 = buf[1];
|
||||
__u32 a = in[0], b = in[1], c = in[2], d = in[3];
|
||||
int n = 16;
|
||||
|
||||
do {
|
||||
sum += DELTA;
|
||||
b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
|
||||
b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
|
||||
} while(--n);
|
||||
|
||||
buf[0] += b0;
|
||||
buf[1] += b1;
|
||||
}
|
||||
|
||||
|
||||
/* The old legacy hash */
|
||||
static __u32 dx_hack_hash_unsigned(const char *name, int len)
|
||||
{
|
||||
__u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
|
||||
const unsigned char *ucp = (const unsigned char *) name;
|
||||
|
||||
while (len--) {
|
||||
hash = hash1 + (hash0 ^ (((int) *ucp++) * 7152373));
|
||||
|
||||
if (hash & 0x80000000)
|
||||
hash -= 0x7fffffff;
|
||||
hash1 = hash0;
|
||||
hash0 = hash;
|
||||
}
|
||||
return hash0 << 1;
|
||||
}
|
||||
|
||||
static __u32 dx_hack_hash_signed(const char *name, int len)
|
||||
{
|
||||
__u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
|
||||
const signed char *scp = (const signed char *) name;
|
||||
|
||||
while (len--) {
|
||||
hash = hash1 + (hash0 ^ (((int) *scp++) * 7152373));
|
||||
|
||||
if (hash & 0x80000000)
|
||||
hash -= 0x7fffffff;
|
||||
hash1 = hash0;
|
||||
hash0 = hash;
|
||||
}
|
||||
return hash0 << 1;
|
||||
}
|
||||
|
||||
static void str2hashbuf_signed(const char *msg, int len, __u32 *buf, int num)
|
||||
{
|
||||
__u32 pad, val;
|
||||
int i;
|
||||
const signed char *scp = (const signed char *) msg;
|
||||
|
||||
pad = (__u32)len | ((__u32)len << 8);
|
||||
pad |= pad << 16;
|
||||
|
||||
val = pad;
|
||||
if (len > num*4)
|
||||
len = num * 4;
|
||||
for (i = 0; i < len; i++) {
|
||||
if ((i % 4) == 0)
|
||||
val = pad;
|
||||
val = ((int) scp[i]) + (val << 8);
|
||||
if ((i % 4) == 3) {
|
||||
*buf++ = val;
|
||||
val = pad;
|
||||
num--;
|
||||
}
|
||||
}
|
||||
if (--num >= 0)
|
||||
*buf++ = val;
|
||||
while (--num >= 0)
|
||||
*buf++ = pad;
|
||||
}
|
||||
|
||||
static void str2hashbuf_unsigned(const char *msg, int len, __u32 *buf, int num)
|
||||
{
|
||||
__u32 pad, val;
|
||||
int i;
|
||||
const unsigned char *ucp = (const unsigned char *) msg;
|
||||
|
||||
pad = (__u32)len | ((__u32)len << 8);
|
||||
pad |= pad << 16;
|
||||
|
||||
val = pad;
|
||||
if (len > num*4)
|
||||
len = num * 4;
|
||||
for (i=0; i < len; i++) {
|
||||
if ((i % 4) == 0)
|
||||
val = pad;
|
||||
val = ((int) ucp[i]) + (val << 8);
|
||||
if ((i % 4) == 3) {
|
||||
*buf++ = val;
|
||||
val = pad;
|
||||
num--;
|
||||
}
|
||||
}
|
||||
if (--num >= 0)
|
||||
*buf++ = val;
|
||||
while (--num >= 0)
|
||||
*buf++ = pad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the hash of a filename. If len is 0 and name is NULL, then
|
||||
* this function can be used to test whether or not a hash version is
|
||||
* supported.
|
||||
*
|
||||
* The seed is an 4 longword (32 bits) "secret" which can be used to
|
||||
* uniquify a hash. If the seed is all zero's, then some default seed
|
||||
* may be used.
|
||||
*
|
||||
* A particular hash version specifies whether or not the seed is
|
||||
* represented, and whether or not the returned hash is 32 bits or 64
|
||||
* bits. 32 bit hashes will return 0 for the minor hash.
|
||||
*/
|
||||
int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
|
||||
{
|
||||
__u32 hash;
|
||||
__u32 minor_hash = 0;
|
||||
const char *p;
|
||||
int i;
|
||||
__u32 in[8], buf[4];
|
||||
void (*str2hashbuf)(const char *, int, __u32 *, int) =
|
||||
str2hashbuf_signed;
|
||||
|
||||
/* Initialize the default seed for the hash checksum functions */
|
||||
buf[0] = 0x67452301;
|
||||
buf[1] = 0xefcdab89;
|
||||
buf[2] = 0x98badcfe;
|
||||
buf[3] = 0x10325476;
|
||||
|
||||
/* Check to see if the seed is all zero's */
|
||||
if (hinfo->seed) {
|
||||
for (i=0; i < 4; i++) {
|
||||
if (hinfo->seed[i])
|
||||
break;
|
||||
}
|
||||
if (i < 4)
|
||||
memcpy(buf, hinfo->seed, sizeof(buf));
|
||||
}
|
||||
|
||||
switch (hinfo->hash_version) {
|
||||
case DX_HASH_LEGACY_UNSIGNED:
|
||||
hash = dx_hack_hash_unsigned(name, len);
|
||||
break;
|
||||
case DX_HASH_LEGACY:
|
||||
hash = dx_hack_hash_signed(name, len);
|
||||
break;
|
||||
case DX_HASH_HALF_MD4_UNSIGNED:
|
||||
str2hashbuf = str2hashbuf_unsigned;
|
||||
case DX_HASH_HALF_MD4:
|
||||
p = name;
|
||||
while (len > 0) {
|
||||
(*str2hashbuf)(p, len, in, 8);
|
||||
half_md4_transform(buf, in);
|
||||
len -= 32;
|
||||
p += 32;
|
||||
}
|
||||
minor_hash = buf[2];
|
||||
hash = buf[1];
|
||||
break;
|
||||
case DX_HASH_TEA_UNSIGNED:
|
||||
str2hashbuf = str2hashbuf_unsigned;
|
||||
case DX_HASH_TEA:
|
||||
p = name;
|
||||
while (len > 0) {
|
||||
(*str2hashbuf)(p, len, in, 4);
|
||||
TEA_transform(buf, in);
|
||||
len -= 16;
|
||||
p += 16;
|
||||
}
|
||||
hash = buf[0];
|
||||
minor_hash = buf[1];
|
||||
break;
|
||||
default:
|
||||
hinfo->hash = 0;
|
||||
return -1;
|
||||
}
|
||||
hash = hash & ~1;
|
||||
if (hash == (EXT3_HTREE_EOF_32BIT << 1))
|
||||
hash = (EXT3_HTREE_EOF_32BIT - 1) << 1;
|
||||
hinfo->hash = hash;
|
||||
hinfo->minor_hash = minor_hash;
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
-3574
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user