@@ -37,7 +37,7 @@ static DEFINE_MUTEX(read_mutex);
37
37
/* These macros may change in future, to provide better st_ino semantics. */
38
38
#define OFFSET (x ) ((x)->i_ino)
39
39
40
- static unsigned long cramino (struct cramfs_inode * cino , unsigned int offset )
40
+ static unsigned long cramino (const struct cramfs_inode * cino , unsigned int offset )
41
41
{
42
42
if (!cino -> offset )
43
43
return offset + 1 ;
@@ -61,7 +61,7 @@ static unsigned long cramino(struct cramfs_inode *cino, unsigned int offset)
61
61
}
62
62
63
63
static struct inode * get_cramfs_inode (struct super_block * sb ,
64
- struct cramfs_inode * cramfs_inode , unsigned int offset )
64
+ const struct cramfs_inode * cramfs_inode , unsigned int offset )
65
65
{
66
66
struct inode * inode ;
67
67
static struct timespec zerotime ;
@@ -317,7 +317,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
317
317
/* Set it all up.. */
318
318
sb -> s_op = & cramfs_ops ;
319
319
root = get_cramfs_inode (sb , & super .root , 0 );
320
- if (! root )
320
+ if (IS_ERR ( root ) )
321
321
goto out ;
322
322
sb -> s_root = d_alloc_root (root );
323
323
if (!sb -> s_root ) {
@@ -423,6 +423,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
423
423
static struct dentry * cramfs_lookup (struct inode * dir , struct dentry * dentry , struct nameidata * nd )
424
424
{
425
425
unsigned int offset = 0 ;
426
+ struct inode * inode = NULL ;
426
427
int sorted ;
427
428
428
429
mutex_lock (& read_mutex );
@@ -449,8 +450,8 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
449
450
450
451
for (;;) {
451
452
if (!namelen ) {
452
- mutex_unlock ( & read_mutex );
453
- return ERR_PTR ( - EIO ) ;
453
+ inode = ERR_PTR ( - EIO );
454
+ goto out ;
454
455
}
455
456
if (name [namelen - 1 ])
456
457
break ;
@@ -462,17 +463,18 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
462
463
if (retval > 0 )
463
464
continue ;
464
465
if (!retval ) {
465
- struct cramfs_inode entry = * de ;
466
- mutex_unlock (& read_mutex );
467
- d_add (dentry , get_cramfs_inode (dir -> i_sb , & entry , dir_off ));
468
- return NULL ;
466
+ inode = get_cramfs_inode (dir -> i_sb , de , dir_off );
467
+ break ;
469
468
}
470
469
/* else (retval < 0) */
471
470
if (sorted )
472
471
break ;
473
472
}
473
+ out :
474
474
mutex_unlock (& read_mutex );
475
- d_add (dentry , NULL );
475
+ if (IS_ERR (inode ))
476
+ return ERR_CAST (inode );
477
+ d_add (dentry , inode );
476
478
return NULL ;
477
479
}
478
480
0 commit comments