@@ -297,19 +297,22 @@ static int do_##type##_##fsop(LIB_FS_##fsop##_OP_ARGS_TYPE) \
297
297
DEF_LIB_FS_OP (cg , getattr )
298
298
DEF_LIB_FS_OP (proc , getattr )
299
299
DEF_LIB_FS_OP (sys , getattr )
300
+ DEF_LIB_FS_OP (lxcfsctl , getattr )
300
301
301
302
#define LIB_FS_read_OP_ARGS_TYPE const char *path, char *buf, size_t size, \
302
303
off_t offset, struct fuse_file_info *fi
303
304
#define LIB_FS_read_OP_ARGS path, buf, size, offset, fi
304
305
DEF_LIB_FS_OP (cg , read )
305
306
DEF_LIB_FS_OP (proc , read )
306
307
DEF_LIB_FS_OP (sys , read )
308
+ DEF_LIB_FS_OP (lxcfsctl , read )
307
309
308
310
#define LIB_FS_write_OP_ARGS_TYPE const char *path, const char *buf, size_t size, \
309
311
off_t offset, struct fuse_file_info *fi
310
312
#define LIB_FS_write_OP_ARGS path, buf, size, offset, fi
311
313
DEF_LIB_FS_OP (cg , write )
312
314
DEF_LIB_FS_OP (sys , write )
315
+ DEF_LIB_FS_OP (lxcfsctl , write )
313
316
314
317
#define LIB_FS_mkdir_OP_ARGS_TYPE const char *path, mode_t mode
315
318
#define LIB_FS_mkdir_OP_ARGS path, mode
@@ -333,38 +336,45 @@ DEF_LIB_FS_OP(cg, chmod)
333
336
DEF_LIB_FS_OP (cg , readdir )
334
337
DEF_LIB_FS_OP (proc , readdir )
335
338
DEF_LIB_FS_OP (sys , readdir )
339
+ DEF_LIB_FS_OP (lxcfsctl , readdir )
336
340
337
341
#define LIB_FS_readlink_OP_ARGS_TYPE const char *path, char *buf, size_t size
338
342
#define LIB_FS_readlink_OP_ARGS path, buf, size
339
343
DEF_LIB_FS_OP (sys , readlink )
344
+ DEF_LIB_FS_OP (lxcfsctl , readlink )
340
345
341
346
#define LIB_FS_open_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
342
347
#define LIB_FS_open_OP_ARGS path, fi
343
348
DEF_LIB_FS_OP (cg , open )
344
349
DEF_LIB_FS_OP (proc , open )
345
350
DEF_LIB_FS_OP (sys , open )
351
+ DEF_LIB_FS_OP (lxcfsctl , open )
346
352
347
353
#define LIB_FS_access_OP_ARGS_TYPE const char *path, int mode
348
354
#define LIB_FS_access_OP_ARGS path, mode
349
355
DEF_LIB_FS_OP (cg , access )
350
356
DEF_LIB_FS_OP (proc , access )
351
357
DEF_LIB_FS_OP (sys , access )
358
+ DEF_LIB_FS_OP (lxcfsctl , access )
352
359
353
360
#define LIB_FS_opendir_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
354
361
#define LIB_FS_opendir_OP_ARGS path, fi
355
362
DEF_LIB_FS_OP (cg , opendir )
356
363
DEF_LIB_FS_OP (sys , opendir )
364
+ DEF_LIB_FS_OP (lxcfsctl , opendir )
357
365
358
366
#define LIB_FS_release_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
359
367
#define LIB_FS_release_OP_ARGS path, fi
360
368
DEF_LIB_FS_OP (cg , release )
361
369
DEF_LIB_FS_OP (proc , release )
362
370
DEF_LIB_FS_OP (sys , release )
371
+ DEF_LIB_FS_OP (lxcfsctl , release )
363
372
364
373
#define LIB_FS_releasedir_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
365
374
#define LIB_FS_releasedir_OP_ARGS path, fi
366
375
DEF_LIB_FS_OP (cg , releasedir )
367
376
DEF_LIB_FS_OP (sys , releasedir )
377
+ DEF_LIB_FS_OP (lxcfsctl , releasedir )
368
378
369
379
static bool cgroup_is_enabled = false;
370
380
@@ -409,6 +419,13 @@ static int lxcfs_getattr(const char *path, struct stat *sb)
409
419
return ret ;
410
420
}
411
421
422
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
423
+ up_users ();
424
+ ret = do_lxcfsctl_getattr (path , sb );
425
+ down_users ();
426
+ return ret ;
427
+ }
428
+
412
429
return - ENOENT ;
413
430
}
414
431
@@ -436,6 +453,13 @@ static int lxcfs_opendir(const char *path, struct fuse_file_info *fi)
436
453
return ret ;
437
454
}
438
455
456
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
457
+ up_users ();
458
+ ret = do_lxcfsctl_opendir (path , fi );
459
+ down_users ();
460
+ return ret ;
461
+ }
462
+
439
463
return - ENOENT ;
440
464
}
441
465
@@ -452,6 +476,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
452
476
if (strcmp (path , "/" ) == 0 ) {
453
477
if (dir_filler (filler , buf , "." , 0 ) != 0 ||
454
478
dir_filler (filler , buf , ".." , 0 ) != 0 ||
479
+ dir_filler (filler , buf , "lxcfs" , 0 ) != 0 ||
455
480
dir_filler (filler , buf , "proc" , 0 ) != 0 ||
456
481
dir_filler (filler , buf , "sys" , 0 ) != 0 ||
457
482
(cgroup_is_enabled && dir_filler (filler , buf , "cgroup" , 0 ) != 0 ))
@@ -481,6 +506,13 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
481
506
return ret ;
482
507
}
483
508
509
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
510
+ up_users ();
511
+ ret = do_lxcfsctl_readdir (path , buf , filler , offset , fi );
512
+ down_users ();
513
+ return ret ;
514
+ }
515
+
484
516
return - ENOENT ;
485
517
}
486
518
@@ -512,6 +544,13 @@ static int lxcfs_access(const char *path, int mode)
512
544
return ret ;
513
545
}
514
546
547
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
548
+ up_users ();
549
+ ret = do_lxcfsctl_access (path , mode );
550
+ down_users ();
551
+ return ret ;
552
+ }
553
+
515
554
return - EACCES ;
516
555
}
517
556
@@ -536,6 +575,13 @@ static int lxcfs_releasedir(const char *path, struct fuse_file_info *fi)
536
575
return ret ;
537
576
}
538
577
578
+ if (LXCFS_TYPE_LXCFS (type )) {
579
+ up_users ();
580
+ ret = do_lxcfsctl_releasedir (path , fi );
581
+ down_users ();
582
+ return ret ;
583
+ }
584
+
539
585
if (path ) {
540
586
if (strcmp (path , "/" ) == 0 )
541
587
return 0 ;
@@ -574,6 +620,13 @@ static int lxcfs_open(const char *path, struct fuse_file_info *fi)
574
620
return ret ;
575
621
}
576
622
623
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
624
+ up_users ();
625
+ ret = do_lxcfsctl_open (path , fi );
626
+ down_users ();
627
+ return ret ;
628
+ }
629
+
577
630
return - EACCES ;
578
631
}
579
632
@@ -603,6 +656,13 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
603
656
return ret ;
604
657
}
605
658
659
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
660
+ up_users ();
661
+ ret = do_lxcfsctl_read (path , buf , size , offset , fi );
662
+ down_users ();
663
+ return ret ;
664
+ }
665
+
606
666
return - EINVAL ;
607
667
}
608
668
@@ -625,6 +685,13 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
625
685
return ret ;
626
686
}
627
687
688
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
689
+ up_users ();
690
+ ret = do_lxcfsctl_write (path , buf , size , offset , fi );
691
+ down_users ();
692
+ return ret ;
693
+ }
694
+
628
695
return - EINVAL ;
629
696
}
630
697
@@ -639,6 +706,13 @@ int lxcfs_readlink(const char *path, char *buf, size_t size)
639
706
return ret ;
640
707
}
641
708
709
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
710
+ up_users ();
711
+ ret = do_lxcfsctl_readlink (path , buf , size );
712
+ down_users ();
713
+ return ret ;
714
+ }
715
+
642
716
return - EINVAL ;
643
717
}
644
718
@@ -675,6 +749,13 @@ static int lxcfs_release(const char *path, struct fuse_file_info *fi)
675
749
return ret ;
676
750
}
677
751
752
+ if (LXCFS_TYPE_LXCFS (type )) {
753
+ up_users ();
754
+ ret = do_lxcfsctl_release (path , fi );
755
+ down_users ();
756
+ return ret ;
757
+ }
758
+
678
759
lxcfs_error ("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64 ,
679
760
path , type , fi -> fh );
680
761
@@ -721,6 +802,9 @@ int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
721
802
if (strncmp (path , "/sys" , 4 ) == 0 )
722
803
return - EPERM ;
723
804
805
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
806
+ return - EPERM ;
807
+
724
808
return - ENOENT ;
725
809
}
726
810
@@ -741,6 +825,9 @@ int lxcfs_truncate(const char *path, off_t newsize)
741
825
if (strncmp (path , "/sys" , 4 ) == 0 )
742
826
return 0 ;
743
827
828
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
829
+ return 0 ;
830
+
744
831
return - EPERM ;
745
832
}
746
833
@@ -779,6 +866,9 @@ int lxcfs_chmod(const char *path, mode_t mode)
779
866
if (strncmp (path , "/sys" , 4 ) == 0 )
780
867
return - EPERM ;
781
868
869
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
870
+ return - EPERM ;
871
+
782
872
return - ENOENT ;
783
873
}
784
874
0 commit comments