summaryrefslogtreecommitdiffstats
path: root/fs/adfs
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
commit59223edaa18759982db0a8aced0e77457d10c68e (patch)
tree89354903b01fa0a447bffeefe00df3044495db2e /fs/adfs
parentdb7d4daea91e105e3859cf461d7e53b9b77454b2 (diff)
Merge with Linux 2.3.6. Sorry, this isn't tested on silicon, I don't
have a MIPS box at hand.
Diffstat (limited to 'fs/adfs')
-rw-r--r--fs/adfs/dir.c52
-rw-r--r--fs/adfs/namei.c6
-rw-r--r--fs/adfs/super.c5
3 files changed, 38 insertions, 25 deletions
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index ac81954d7..738bb40b8 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -76,13 +76,34 @@ unsigned int adfs_val (unsigned char *p, int len)
return val;
}
+static unsigned int adfs_filetype (unsigned int load)
+{
+ if ((load & 0xfff00000) != 0xfff00000)
+ return (unsigned int) -1;
+ return (load >> 8) & 0xfff;
+}
+
static unsigned int adfs_time (unsigned int load, unsigned int exec)
{
unsigned int high, low;
- high = ((load << 24) | (exec >> 8)) - 0x336e996a;
+ /* Check for unstamped files. */
+ if ((load & 0xfff00000) != 0xfff00000)
+ return 0;
+
+ high = ((load << 24) | (exec >> 8));
low = exec & 255;
+ /* Files dated pre 1970. */
+ if (high < 0x336e996a)
+ return 0;
+
+ high -= 0x336e996a;
+
+ /* Files dated post 2038 ish. */
+ if (high > 0x31ffffff)
+ return 0x7fffffff;
+
/* 65537 = h256,l1
* (h256 % 100) = 56 h256 / 100 = 2
* 56 << 8 = 14336 2 * 256 = 512
@@ -117,9 +138,6 @@ int adfs_dir_read_parent (struct inode *inode, struct buffer_head **bhp)
struct super_block *sb;
int i, size;
- if (!inode)
- return 0;
-
sb = inode->i_sb;
size = 2048 >> sb->s_blocksize_bits;
@@ -204,6 +222,18 @@ void adfs_dir_free (struct buffer_head **bhp, int buffers)
brelse (bhp[i]);
}
+/* convert a disk-based directory entry to a Linux ADFS directory entry */
+static inline void
+adfs_dirent_to_idirent(struct adfs_idir_entry *ide, struct adfs_direntry *de)
+{
+ ide->name_len = adfs_readname(ide->name, de->dirobname, ADFS_NAME_LEN);
+ ide->file_id = adfs_val(de->dirinddiscadd, 3);
+ ide->size = adfs_val(de->dirlen, 4);
+ ide->mode = de->newdiratts;
+ ide->mtime = adfs_time(adfs_val(de->dirload, 4), adfs_val(de->direxec, 4));
+ ide->filetype = adfs_filetype(adfs_val(de->dirload, 4));
+}
+
int adfs_dir_get (struct super_block *sb, struct buffer_head **bhp,
int buffers, int pos, unsigned long parent_object_id,
struct adfs_idir_entry *ide)
@@ -228,13 +258,8 @@ int adfs_dir_get (struct super_block *sb, struct buffer_head **bhp,
if (!de.dirobname[0])
return 0;
- ide->name_len = adfs_readname (ide->name, de.dirobname, ADFS_NAME_LEN);
ide->inode_no = adfs_inode_generate (parent_object_id, pos);
- ide->file_id = adfs_val (de.dirinddiscadd, 3);
- ide->size = adfs_val (de.dirlen, 4);
- ide->mode = de.newdiratts;
- ide->mtime = adfs_time (adfs_val (de.dirload, 4), adfs_val (de.direxec, 4));
- ide->filetype = (adfs_val (de.dirload, 4) >> 8) & 0xfff;
+ adfs_dirent_to_idirent(ide, &de);
return 1;
}
@@ -262,12 +287,7 @@ int adfs_dir_find_entry (struct super_block *sb, struct buffer_head **bhp,
if (!de.dirobname[0])
return 0;
- ide->name_len = adfs_readname (ide->name, de.dirobname, ADFS_NAME_LEN);
- ide->size = adfs_val (de.dirlen, 4);
- ide->mode = de.newdiratts;
- ide->file_id = adfs_val (de.dirinddiscadd, 3);
- ide->mtime = adfs_time (adfs_val (de.dirload, 4), adfs_val (de.direxec, 4));
- ide->filetype = (adfs_val (de.dirload, 4) >> 8) & 0xfff;
+ adfs_dirent_to_idirent(ide, &de);
return 1;
}
diff --git a/fs/adfs/namei.c b/fs/adfs/namei.c
index df3b5e457..4e41c0975 100644
--- a/fs/adfs/namei.c
+++ b/fs/adfs/namei.c
@@ -46,9 +46,6 @@ static int adfs_find_entry (struct inode *dir, const char * const name, int name
unsigned long parent_object_id, dir_object_id;
int buffers, pos;
- if (!S_ISDIR(dir->i_mode))
- return 0;
-
sb = dir->i_sb;
if (adfs_inode_validate (dir)) {
@@ -57,9 +54,6 @@ static int adfs_find_entry (struct inode *dir, const char * const name, int name
return 0;
}
- if (namelen > ADFS_NAME_LEN)
- return 0;
-
if (!(buffers = adfs_dir_read (dir, bh))) {
adfs_error (sb, "adfs_find_entry", "unable to read directory");
return 0;
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 8c2fbe8fa..e5f54f414 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -300,7 +300,7 @@ struct super_block *adfs_read_super(struct super_block *sb, void *data, int sile
*/
sb->s_op = &adfs_sops;
sb->u.adfs_sb.s_root = adfs_inode_generate(dr->root, 0);
- sb->s_root = d_alloc_root(iget(sb, sb->u.adfs_sb.s_root), NULL);
+ sb->s_root = d_alloc_root(iget(sb, sb->u.adfs_sb.s_root));
if (!sb->s_root) {
for (i = 0; i < sb->u.adfs_sb.s_map_size; i++)
@@ -312,8 +312,7 @@ struct super_block *adfs_read_super(struct super_block *sb, void *data, int sile
return sb;
error_free_bh:
- if (bh)
- brelse(bh);
+ brelse(bh);
error_unlock:
unlock_super(sb);
error_dec_use: