@@ -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
@@ -455,6 +479,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
455
479
if (strcmp (path , "/" ) == 0 ) {
456
480
if (dir_filler (filler , buf , "." , 0 ) != 0 ||
457
481
dir_filler (filler , buf , ".." , 0 ) != 0 ||
482
+ dir_filler (filler , buf , "lxcfs" , 0 ) != 0 ||
458
483
dir_filler (filler , buf , "proc" , 0 ) != 0 ||
459
484
dir_filler (filler , buf , "sys" , 0 ) != 0 ||
460
485
(cgroup_is_enabled && dir_filler (filler , buf , "cgroup" , 0 ) != 0 ))
@@ -484,6 +509,13 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
484
509
return ret ;
485
510
}
486
511
512
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
513
+ up_users ();
514
+ ret = do_lxcfsctl_readdir (path , buf , filler , offset , fi );
515
+ down_users ();
516
+ return ret ;
517
+ }
518
+
487
519
return - ENOENT ;
488
520
}
489
521
@@ -515,6 +547,13 @@ static int lxcfs_access(const char *path, int mode)
515
547
return ret ;
516
548
}
517
549
550
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
551
+ up_users ();
552
+ ret = do_lxcfsctl_access (path , mode );
553
+ down_users ();
554
+ return ret ;
555
+ }
556
+
518
557
return - EACCES ;
519
558
}
520
559
@@ -539,6 +578,13 @@ static int lxcfs_releasedir(const char *path, struct fuse_file_info *fi)
539
578
return ret ;
540
579
}
541
580
581
+ if (LXCFS_TYPE_LXCFS (type )) {
582
+ up_users ();
583
+ ret = do_lxcfsctl_releasedir (path , fi );
584
+ down_users ();
585
+ return ret ;
586
+ }
587
+
542
588
if (path ) {
543
589
if (strcmp (path , "/" ) == 0 )
544
590
return 0 ;
@@ -577,6 +623,13 @@ static int lxcfs_open(const char *path, struct fuse_file_info *fi)
577
623
return ret ;
578
624
}
579
625
626
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
627
+ up_users ();
628
+ ret = do_lxcfsctl_open (path , fi );
629
+ down_users ();
630
+ return ret ;
631
+ }
632
+
580
633
return - EACCES ;
581
634
}
582
635
@@ -609,6 +662,13 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
609
662
return ret ;
610
663
}
611
664
665
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
666
+ up_users ();
667
+ ret = do_lxcfsctl_read (path , buf , size , offset , fi );
668
+ down_users ();
669
+ return ret ;
670
+ }
671
+
612
672
lxcfs_error ("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64 ,
613
673
path , type , fi -> fh );
614
674
@@ -637,6 +697,13 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
637
697
return ret ;
638
698
}
639
699
700
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
701
+ up_users ();
702
+ ret = do_lxcfsctl_write (path , buf , size , offset , fi );
703
+ down_users ();
704
+ return ret ;
705
+ }
706
+
640
707
return - EINVAL ;
641
708
}
642
709
@@ -651,6 +718,13 @@ int lxcfs_readlink(const char *path, char *buf, size_t size)
651
718
return ret ;
652
719
}
653
720
721
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
722
+ up_users ();
723
+ ret = do_lxcfsctl_readlink (path , buf , size );
724
+ down_users ();
725
+ return ret ;
726
+ }
727
+
654
728
return - EINVAL ;
655
729
}
656
730
@@ -687,6 +761,13 @@ static int lxcfs_release(const char *path, struct fuse_file_info *fi)
687
761
return ret ;
688
762
}
689
763
764
+ if (LXCFS_TYPE_LXCFS (type )) {
765
+ up_users ();
766
+ ret = do_lxcfsctl_release (path , fi );
767
+ down_users ();
768
+ return ret ;
769
+ }
770
+
690
771
lxcfs_error ("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64 ,
691
772
path , type , fi -> fh );
692
773
@@ -733,6 +814,9 @@ int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
733
814
if (strncmp (path , "/sys" , 4 ) == 0 )
734
815
return - EPERM ;
735
816
817
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
818
+ return - EPERM ;
819
+
736
820
return - ENOENT ;
737
821
}
738
822
@@ -753,6 +837,9 @@ int lxcfs_truncate(const char *path, off_t newsize)
753
837
if (strncmp (path , "/sys" , 4 ) == 0 )
754
838
return 0 ;
755
839
840
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
841
+ return 0 ;
842
+
756
843
return - EPERM ;
757
844
}
758
845
@@ -791,6 +878,9 @@ int lxcfs_chmod(const char *path, mode_t mode)
791
878
if (strncmp (path , "/sys" , 4 ) == 0 )
792
879
return - EPERM ;
793
880
881
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
882
+ return - EPERM ;
883
+
794
884
return - ENOENT ;
795
885
}
796
886
0 commit comments