@@ -412,6 +412,25 @@ static void update_inode_attr(struct dentry *dentry, struct inode *inode,
412
412
inode -> i_gid = attr -> gid ;
413
413
}
414
414
415
+ static struct inode * eventfs_get_inode (struct dentry * dentry , struct eventfs_attr * attr ,
416
+ umode_t mode , struct eventfs_inode * ei )
417
+ {
418
+ struct tracefs_inode * ti ;
419
+ struct inode * inode ;
420
+
421
+ inode = tracefs_get_inode (dentry -> d_sb );
422
+ if (!inode )
423
+ return NULL ;
424
+
425
+ ti = get_tracefs (inode );
426
+ ti -> private = ei ;
427
+ ti -> flags |= TRACEFS_EVENT_INODE ;
428
+
429
+ update_inode_attr (dentry , inode , attr , mode );
430
+
431
+ return inode ;
432
+ }
433
+
415
434
/**
416
435
* lookup_file - look up a file in the tracefs filesystem
417
436
* @parent_ei: Pointer to the eventfs_inode that represents parent of the file
@@ -432,7 +451,6 @@ static struct dentry *lookup_file(struct eventfs_inode *parent_ei,
432
451
void * data ,
433
452
const struct file_operations * fop )
434
453
{
435
- struct tracefs_inode * ti ;
436
454
struct inode * inode ;
437
455
438
456
if (!(mode & S_IFMT ))
@@ -441,23 +459,18 @@ static struct dentry *lookup_file(struct eventfs_inode *parent_ei,
441
459
if (WARN_ON_ONCE (!S_ISREG (mode )))
442
460
return ERR_PTR (- EIO );
443
461
444
- inode = tracefs_get_inode (dentry -> d_sb );
462
+ /* Only directories have ti->private set to an ei, not files */
463
+ inode = eventfs_get_inode (dentry , attr , mode , NULL );
445
464
if (unlikely (!inode ))
446
465
return ERR_PTR (- ENOMEM );
447
466
448
- /* If the user updated the directory's attributes, use them */
449
- update_inode_attr (dentry , inode , attr , mode );
450
-
451
467
inode -> i_op = & eventfs_file_inode_operations ;
452
468
inode -> i_fop = fop ;
453
469
inode -> i_private = data ;
454
470
455
471
/* All files will have the same inode number */
456
472
inode -> i_ino = EVENTFS_FILE_INODE_INO ;
457
473
458
- ti = get_tracefs (inode );
459
- ti -> flags |= TRACEFS_EVENT_INODE ;
460
-
461
474
// Files have their parent's ei as their fsdata
462
475
dentry -> d_fsdata = get_ei (parent_ei );
463
476
@@ -477,28 +490,19 @@ static struct dentry *lookup_file(struct eventfs_inode *parent_ei,
477
490
static struct dentry * lookup_dir_entry (struct dentry * dentry ,
478
491
struct eventfs_inode * pei , struct eventfs_inode * ei )
479
492
{
480
- struct tracefs_inode * ti ;
481
493
struct inode * inode ;
494
+ umode_t mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO ;
482
495
483
- inode = tracefs_get_inode (dentry -> d_sb );
496
+ inode = eventfs_get_inode (dentry , & ei -> attr , mode , ei );
484
497
if (unlikely (!inode ))
485
498
return ERR_PTR (- ENOMEM );
486
499
487
- /* If the user updated the directory's attributes, use them */
488
- update_inode_attr (dentry , inode , & ei -> attr ,
489
- S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO );
490
-
491
500
inode -> i_op = & eventfs_dir_inode_operations ;
492
501
inode -> i_fop = & eventfs_file_operations ;
493
502
494
503
/* All directories will have the same inode number */
495
504
inode -> i_ino = eventfs_dir_ino (ei );
496
505
497
- ti = get_tracefs (inode );
498
- ti -> flags |= TRACEFS_EVENT_INODE ;
499
- /* Only directories have ti->private set to an ei, not files */
500
- ti -> private = ei ;
501
-
502
506
dentry -> d_fsdata = get_ei (ei );
503
507
504
508
d_add (dentry , inode );
0 commit comments