diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-03-17 22:05:47 +0000 |
commit | 27cfca1ec98e91261b1a5355d10a8996464b63af (patch) | |
tree | 8e895a53e372fa682b4c0a585b9377d67ed70d0e /fs/hfs/sysdep.c | |
parent | 6a76fb7214c477ccf6582bd79c5b4ccc4f9c41b1 (diff) |
Look Ma' what I found on my harddisk ...
o New faster syscalls for 2.1.x, too
o Upgrade to 2.1.89.
Don't try to run this. It's flaky as hell. But feel free to debug ...
Diffstat (limited to 'fs/hfs/sysdep.c')
-rw-r--r-- | fs/hfs/sysdep.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/fs/hfs/sysdep.c b/fs/hfs/sysdep.c new file mode 100644 index 000000000..fc7368a75 --- /dev/null +++ b/fs/hfs/sysdep.c @@ -0,0 +1,103 @@ +/* + * linux/fs/hfs/sysdep.c + * + * Copyright (C) 1996 Paul H. Hargrove + * This file may be distributed under the terms of the GNU Public License. + * + * This file contains the code to do various system dependent things. + * + * "XXX" in a comment is a note to myself to consider changing something. + * + * In function preconditions the term "valid" applied to a pointer to + * a structure means that the pointer is non-NULL and the structure it + * points to has all fields initialized to consistent values. + */ + +#include "hfs.h" +#include <linux/hfs_fs_sb.h> +#include <linux/hfs_fs_i.h> +#include <linux/hfs_fs.h> + +static int hfs_hash_dentry(struct dentry *, struct qstr *); +static int hfs_compare_dentry (struct dentry *, struct qstr *, struct qstr *); +struct dentry_operations hfs_dentry_operations = +{ + NULL, /* d_validate(struct dentry *) */ + hfs_hash_dentry, /* d_hash */ + hfs_compare_dentry, /* d_compare */ + NULL /* d_delete(struct dentry *) */ +}; + +/* + * hfs_buffer_get() + * + * Return a buffer for the 'block'th block of the media. + * If ('read'==0) then the buffer is not read from disk. + */ +hfs_buffer hfs_buffer_get(hfs_sysmdb sys_mdb, int block, int read) { + hfs_buffer tmp = HFS_BAD_BUFFER; + + if (read) { + tmp = bread(sys_mdb->s_dev, block, HFS_SECTOR_SIZE); + } else { + tmp = getblk(sys_mdb->s_dev, block, HFS_SECTOR_SIZE); + if (tmp) { + mark_buffer_uptodate(tmp, 1); + } + } + if (!tmp) { + hfs_error("hfs_fs: unable to read block 0x%08x from dev %s\n", + block, hfs_mdb_name(sys_mdb)); + } + + return tmp; +} + +/* dentry case-handling: just lowercase everything */ + +/* should we use hfs_strhash? if so, it probably needs to be beefed + * up a little. */ +static int hfs_hash_dentry(struct dentry *dentry, struct qstr *this) +{ + unsigned char name[HFS_NAMELEN]; + int len = this->len; + + if (len > HFS_NAMELEN) + return 0; + + strncpy(name, this->name, len); + hfs_tolower(name, len); + this->hash = full_name_hash(name, len); + return 0; +} + +static int hfs_compare_dentry(struct dentry *dentry, struct qstr *a, + struct qstr *b) +{ + struct hfs_name s1, s2; + + if (a->len != b->len) return 1; + + if ((s1.Len = s2.Len = a->len) > HFS_NAMELEN) + return 1; + + strncpy(s1.Name, a->name, s1.Len); + strncpy(s2.Name, b->name, s2.Len); + return hfs_streq(&s1, &s2); +} + + +/* toss a catalog entry. this does it by dropping the dentry. */ +void hfs_cat_prune(struct hfs_cat_entry *entry) +{ + int i; + + for (i = 0; i < 4; i++) { + struct dentry *de = entry->sys_entry[i]; + if (de) { + dget(de); + d_drop(de); + dput(de); + } + } +} |