@@ -364,13 +364,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
364
364
return error ;
365
365
}
366
366
367
- SYSCALL_DEFINE5 ( setxattr , const char __user * , pathname ,
368
- const char __user * , name , const void __user * , value ,
369
- size_t , size , int , flags )
367
+ static int path_setxattr ( const char __user * pathname ,
368
+ const char __user * name , const void __user * value ,
369
+ size_t size , int flags , unsigned int lookup_flags )
370
370
{
371
371
struct path path ;
372
372
int error ;
373
- unsigned int lookup_flags = LOOKUP_FOLLOW ;
374
373
retry :
375
374
error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
376
375
if (error )
@@ -388,28 +387,18 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname,
388
387
return error ;
389
388
}
390
389
390
+ SYSCALL_DEFINE5 (setxattr , const char __user * , pathname ,
391
+ const char __user * , name , const void __user * , value ,
392
+ size_t , size , int , flags )
393
+ {
394
+ return path_setxattr (pathname , name , value , size , flags , LOOKUP_FOLLOW );
395
+ }
396
+
391
397
SYSCALL_DEFINE5 (lsetxattr , const char __user * , pathname ,
392
398
const char __user * , name , const void __user * , value ,
393
399
size_t , size , int , flags )
394
400
{
395
- struct path path ;
396
- int error ;
397
- unsigned int lookup_flags = 0 ;
398
- retry :
399
- error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
400
- if (error )
401
- return error ;
402
- error = mnt_want_write (path .mnt );
403
- if (!error ) {
404
- error = setxattr (path .dentry , name , value , size , flags );
405
- mnt_drop_write (path .mnt );
406
- }
407
- path_put (& path );
408
- if (retry_estale (error , lookup_flags )) {
409
- lookup_flags |= LOOKUP_REVAL ;
410
- goto retry ;
411
- }
412
- return error ;
401
+ return path_setxattr (pathname , name , value , size , flags , 0 );
413
402
}
414
403
415
404
SYSCALL_DEFINE5 (fsetxattr , int , fd , const char __user * , name ,
@@ -481,12 +470,12 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
481
470
return error ;
482
471
}
483
472
484
- SYSCALL_DEFINE4 (getxattr , const char __user * , pathname ,
485
- const char __user * , name , void __user * , value , size_t , size )
473
+ static ssize_t path_getxattr (const char __user * pathname ,
474
+ const char __user * name , void __user * value ,
475
+ size_t size , unsigned int lookup_flags )
486
476
{
487
477
struct path path ;
488
478
ssize_t error ;
489
- unsigned int lookup_flags = LOOKUP_FOLLOW ;
490
479
retry :
491
480
error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
492
481
if (error )
@@ -500,23 +489,16 @@ SYSCALL_DEFINE4(getxattr, const char __user *, pathname,
500
489
return error ;
501
490
}
502
491
492
+ SYSCALL_DEFINE4 (getxattr , const char __user * , pathname ,
493
+ const char __user * , name , void __user * , value , size_t , size )
494
+ {
495
+ return path_getxattr (pathname , name , value , size , LOOKUP_FOLLOW );
496
+ }
497
+
503
498
SYSCALL_DEFINE4 (lgetxattr , const char __user * , pathname ,
504
499
const char __user * , name , void __user * , value , size_t , size )
505
500
{
506
- struct path path ;
507
- ssize_t error ;
508
- unsigned int lookup_flags = 0 ;
509
- retry :
510
- error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
511
- if (error )
512
- return error ;
513
- error = getxattr (path .dentry , name , value , size );
514
- path_put (& path );
515
- if (retry_estale (error , lookup_flags )) {
516
- lookup_flags |= LOOKUP_REVAL ;
517
- goto retry ;
518
- }
519
- return error ;
501
+ return path_getxattr (pathname , name , value , size , 0 );
520
502
}
521
503
522
504
SYSCALL_DEFINE4 (fgetxattr , int , fd , const char __user * , name ,
@@ -571,12 +553,11 @@ listxattr(struct dentry *d, char __user *list, size_t size)
571
553
return error ;
572
554
}
573
555
574
- SYSCALL_DEFINE3 ( listxattr , const char __user * , pathname , char __user * , list ,
575
- size_t , size )
556
+ static ssize_t path_listxattr ( const char __user * pathname , char __user * list ,
557
+ size_t size , unsigned int lookup_flags )
576
558
{
577
559
struct path path ;
578
560
ssize_t error ;
579
- unsigned int lookup_flags = LOOKUP_FOLLOW ;
580
561
retry :
581
562
error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
582
563
if (error )
@@ -590,23 +571,16 @@ SYSCALL_DEFINE3(listxattr, const char __user *, pathname, char __user *, list,
590
571
return error ;
591
572
}
592
573
574
+ SYSCALL_DEFINE3 (listxattr , const char __user * , pathname , char __user * , list ,
575
+ size_t , size )
576
+ {
577
+ return path_listxattr (pathname , list , size , LOOKUP_FOLLOW );
578
+ }
579
+
593
580
SYSCALL_DEFINE3 (llistxattr , const char __user * , pathname , char __user * , list ,
594
581
size_t , size )
595
582
{
596
- struct path path ;
597
- ssize_t error ;
598
- unsigned int lookup_flags = 0 ;
599
- retry :
600
- error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
601
- if (error )
602
- return error ;
603
- error = listxattr (path .dentry , list , size );
604
- path_put (& path );
605
- if (retry_estale (error , lookup_flags )) {
606
- lookup_flags |= LOOKUP_REVAL ;
607
- goto retry ;
608
- }
609
- return error ;
583
+ return path_listxattr (pathname , list , size , 0 );
610
584
}
611
585
612
586
SYSCALL_DEFINE3 (flistxattr , int , fd , char __user * , list , size_t , size )
@@ -640,12 +614,11 @@ removexattr(struct dentry *d, const char __user *name)
640
614
return vfs_removexattr (d , kname );
641
615
}
642
616
643
- SYSCALL_DEFINE2 ( removexattr , const char __user * , pathname ,
644
- const char __user * , name )
617
+ static int path_removexattr ( const char __user * pathname ,
618
+ const char __user * name , unsigned int lookup_flags )
645
619
{
646
620
struct path path ;
647
621
int error ;
648
- unsigned int lookup_flags = LOOKUP_FOLLOW ;
649
622
retry :
650
623
error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
651
624
if (error )
@@ -663,27 +636,16 @@ SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
663
636
return error ;
664
637
}
665
638
639
+ SYSCALL_DEFINE2 (removexattr , const char __user * , pathname ,
640
+ const char __user * , name )
641
+ {
642
+ return path_removexattr (pathname , name , LOOKUP_FOLLOW );
643
+ }
644
+
666
645
SYSCALL_DEFINE2 (lremovexattr , const char __user * , pathname ,
667
646
const char __user * , name )
668
647
{
669
- struct path path ;
670
- int error ;
671
- unsigned int lookup_flags = 0 ;
672
- retry :
673
- error = user_path_at (AT_FDCWD , pathname , lookup_flags , & path );
674
- if (error )
675
- return error ;
676
- error = mnt_want_write (path .mnt );
677
- if (!error ) {
678
- error = removexattr (path .dentry , name );
679
- mnt_drop_write (path .mnt );
680
- }
681
- path_put (& path );
682
- if (retry_estale (error , lookup_flags )) {
683
- lookup_flags |= LOOKUP_REVAL ;
684
- goto retry ;
685
- }
686
- return error ;
648
+ return path_removexattr (pathname , name , 0 );
687
649
}
688
650
689
651
SYSCALL_DEFINE2 (fremovexattr , int , fd , const char __user * , name )
0 commit comments