2 * linux/fs/hfs/sysdep.c
4 * Copyright (C) 1996 Paul H. Hargrove
5 * This file may be distributed under the terms of the GNU General Public License.
7 * This file contains the code to do various system dependent things.
9 * "XXX" in a comment is a note to myself to consider changing something.
11 * In function preconditions the term "valid" applied to a pointer to
12 * a structure means that the pointer is non-NULL and the structure it
13 * points to has all fields initialized to consistent values.
17 #include <linux/hfs_fs_sb.h>
18 #include <linux/hfs_fs_i.h>
19 #include <linux/hfs_fs.h>
20 #include <linux/smp_lock.h>
22 static int hfs_revalidate_dentry(struct dentry *, int);
23 static int hfs_hash_dentry(struct dentry *, struct qstr *);
24 static int hfs_compare_dentry(struct dentry *, struct qstr *, struct qstr *);
25 static void hfs_dentry_iput(struct dentry *, struct inode *);
26 struct dentry_operations hfs_dentry_operations =
28 d_revalidate: hfs_revalidate_dentry,
29 d_hash: hfs_hash_dentry,
30 d_compare: hfs_compare_dentry,
31 d_iput: hfs_dentry_iput,
37 * Return a buffer for the 'block'th block of the media.
38 * If ('read'==0) then the buffer is not read from disk.
40 hfs_buffer hfs_buffer_get(hfs_sysmdb sys_mdb, int block, int read) {
41 hfs_buffer tmp = HFS_BAD_BUFFER;
44 tmp = sb_bread(sys_mdb, block);
46 tmp = sb_getblk(sys_mdb, block);
48 mark_buffer_uptodate(tmp, 1);
52 hfs_error("hfs_fs: unable to read block 0x%08x from dev %s\n",
53 block, hfs_mdb_name(sys_mdb));
59 /* dentry case-handling: just lowercase everything */
61 /* hfs_strhash now uses the same hashing function as the dcache. */
62 static int hfs_hash_dentry(struct dentry *dentry, struct qstr *this)
64 if (this->len > HFS_NAMELEN)
67 this->hash = hfs_strhash(this->name, this->len);
71 /* return 1 on failure and 0 on success */
72 static int hfs_compare_dentry(struct dentry *dentry, struct qstr *a,
75 if (a->len != b->len) return 1;
77 if (a->len > HFS_NAMELEN)
80 return !hfs_streq(a->name, a->len, b->name, b->len);
83 static void hfs_dentry_iput(struct dentry *dentry, struct inode *inode)
85 struct hfs_cat_entry *entry = HFS_I(inode)->entry;
88 entry->sys_entry[HFS_ITYPE_TO_INT(HFS_ITYPE(inode->i_ino))] = NULL;
93 static int hfs_revalidate_dentry(struct dentry *dentry, int flags)
95 struct inode *inode = dentry->d_inode;
98 /* fix up inode on a timezone change */
101 (diff = (hfs_to_utc(0) - HFS_I(inode)->tz_secondswest))) {
102 inode->i_ctime += diff;
103 inode->i_atime += diff;
104 inode->i_mtime += diff;
105 HFS_I(inode)->tz_secondswest += diff;