@@ -294,19 +294,22 @@ static int do_##type##_##fsop(LIB_FS_##fsop##_OP_ARGS_TYPE) \
294
294
DEF_LIB_FS_OP (cg , getattr )
295
295
DEF_LIB_FS_OP (proc , getattr )
296
296
DEF_LIB_FS_OP (sys , getattr )
297
+ DEF_LIB_FS_OP (lxcfsctl , getattr )
297
298
298
299
#define LIB_FS_read_OP_ARGS_TYPE const char *path, char *buf, size_t size, \
299
300
off_t offset, struct fuse_file_info *fi
300
301
#define LIB_FS_read_OP_ARGS path, buf, size, offset, fi
301
302
DEF_LIB_FS_OP (cg , read )
302
303
DEF_LIB_FS_OP (proc , read )
303
304
DEF_LIB_FS_OP (sys , read )
305
+ DEF_LIB_FS_OP (lxcfsctl , read )
304
306
305
307
#define LIB_FS_write_OP_ARGS_TYPE const char *path, const char *buf, size_t size, \
306
308
off_t offset, struct fuse_file_info *fi
307
309
#define LIB_FS_write_OP_ARGS path, buf, size, offset, fi
308
310
DEF_LIB_FS_OP (cg , write )
309
311
DEF_LIB_FS_OP (sys , write )
312
+ DEF_LIB_FS_OP (lxcfsctl , write )
310
313
311
314
#define LIB_FS_mkdir_OP_ARGS_TYPE const char *path, mode_t mode
312
315
#define LIB_FS_mkdir_OP_ARGS path, mode
@@ -330,38 +333,45 @@ DEF_LIB_FS_OP(cg, chmod)
330
333
DEF_LIB_FS_OP (cg , readdir )
331
334
DEF_LIB_FS_OP (proc , readdir )
332
335
DEF_LIB_FS_OP (sys , readdir )
336
+ DEF_LIB_FS_OP (lxcfsctl , readdir )
333
337
334
338
#define LIB_FS_readlink_OP_ARGS_TYPE const char *path, char *buf, size_t size
335
339
#define LIB_FS_readlink_OP_ARGS path, buf, size
336
340
DEF_LIB_FS_OP (sys , readlink )
341
+ DEF_LIB_FS_OP (lxcfsctl , readlink )
337
342
338
343
#define LIB_FS_open_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
339
344
#define LIB_FS_open_OP_ARGS path, fi
340
345
DEF_LIB_FS_OP (cg , open )
341
346
DEF_LIB_FS_OP (proc , open )
342
347
DEF_LIB_FS_OP (sys , open )
348
+ DEF_LIB_FS_OP (lxcfsctl , open )
343
349
344
350
#define LIB_FS_access_OP_ARGS_TYPE const char *path, int mode
345
351
#define LIB_FS_access_OP_ARGS path, mode
346
352
DEF_LIB_FS_OP (cg , access )
347
353
DEF_LIB_FS_OP (proc , access )
348
354
DEF_LIB_FS_OP (sys , access )
355
+ DEF_LIB_FS_OP (lxcfsctl , access )
349
356
350
357
#define LIB_FS_opendir_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
351
358
#define LIB_FS_opendir_OP_ARGS path, fi
352
359
DEF_LIB_FS_OP (cg , opendir )
353
360
DEF_LIB_FS_OP (sys , opendir )
361
+ DEF_LIB_FS_OP (lxcfsctl , opendir )
354
362
355
363
#define LIB_FS_release_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
356
364
#define LIB_FS_release_OP_ARGS path, fi
357
365
DEF_LIB_FS_OP (cg , release )
358
366
DEF_LIB_FS_OP (proc , release )
359
367
DEF_LIB_FS_OP (sys , release )
368
+ DEF_LIB_FS_OP (lxcfsctl , release )
360
369
361
370
#define LIB_FS_releasedir_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi
362
371
#define LIB_FS_releasedir_OP_ARGS path, fi
363
372
DEF_LIB_FS_OP (cg , releasedir )
364
373
DEF_LIB_FS_OP (sys , releasedir )
374
+ DEF_LIB_FS_OP (lxcfsctl , releasedir )
365
375
366
376
static bool cgroup_is_enabled = false;
367
377
@@ -406,6 +416,13 @@ static int lxcfs_getattr(const char *path, struct stat *sb)
406
416
return ret ;
407
417
}
408
418
419
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
420
+ up_users ();
421
+ ret = do_lxcfsctl_getattr (path , sb );
422
+ down_users ();
423
+ return ret ;
424
+ }
425
+
409
426
return - ENOENT ;
410
427
}
411
428
@@ -433,6 +450,13 @@ static int lxcfs_opendir(const char *path, struct fuse_file_info *fi)
433
450
return ret ;
434
451
}
435
452
453
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
454
+ up_users ();
455
+ ret = do_lxcfsctl_opendir (path , fi );
456
+ down_users ();
457
+ return ret ;
458
+ }
459
+
436
460
return - ENOENT ;
437
461
}
438
462
@@ -449,6 +473,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
449
473
if (strcmp (path , "/" ) == 0 ) {
450
474
if (dir_filler (filler , buf , "." , 0 ) != 0 ||
451
475
dir_filler (filler , buf , ".." , 0 ) != 0 ||
476
+ dir_filler (filler , buf , "lxcfs" , 0 ) != 0 ||
452
477
dir_filler (filler , buf , "proc" , 0 ) != 0 ||
453
478
dir_filler (filler , buf , "sys" , 0 ) != 0 ||
454
479
(cgroup_is_enabled && dir_filler (filler , buf , "cgroup" , 0 ) != 0 ))
@@ -478,6 +503,13 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
478
503
return ret ;
479
504
}
480
505
506
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
507
+ up_users ();
508
+ ret = do_lxcfsctl_readdir (path , buf , filler , offset , fi );
509
+ down_users ();
510
+ return ret ;
511
+ }
512
+
481
513
return - ENOENT ;
482
514
}
483
515
@@ -509,6 +541,13 @@ static int lxcfs_access(const char *path, int mode)
509
541
return ret ;
510
542
}
511
543
544
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
545
+ up_users ();
546
+ ret = do_lxcfsctl_access (path , mode );
547
+ down_users ();
548
+ return ret ;
549
+ }
550
+
512
551
return - EACCES ;
513
552
}
514
553
@@ -533,6 +572,13 @@ static int lxcfs_releasedir(const char *path, struct fuse_file_info *fi)
533
572
return ret ;
534
573
}
535
574
575
+ if (LXCFS_TYPE_LXCFS (type )) {
576
+ up_users ();
577
+ ret = do_lxcfsctl_releasedir (path , fi );
578
+ down_users ();
579
+ return ret ;
580
+ }
581
+
536
582
if (path ) {
537
583
if (strcmp (path , "/" ) == 0 )
538
584
return 0 ;
@@ -571,6 +617,13 @@ static int lxcfs_open(const char *path, struct fuse_file_info *fi)
571
617
return ret ;
572
618
}
573
619
620
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
621
+ up_users ();
622
+ ret = do_lxcfsctl_open (path , fi );
623
+ down_users ();
624
+ return ret ;
625
+ }
626
+
574
627
return - EACCES ;
575
628
}
576
629
@@ -600,6 +653,13 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
600
653
return ret ;
601
654
}
602
655
656
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
657
+ up_users ();
658
+ ret = do_lxcfsctl_read (path , buf , size , offset , fi );
659
+ down_users ();
660
+ return ret ;
661
+ }
662
+
603
663
return - EINVAL ;
604
664
}
605
665
@@ -622,6 +682,13 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
622
682
return ret ;
623
683
}
624
684
685
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
686
+ up_users ();
687
+ ret = do_lxcfsctl_write (path , buf , size , offset , fi );
688
+ down_users ();
689
+ return ret ;
690
+ }
691
+
625
692
return - EINVAL ;
626
693
}
627
694
@@ -636,6 +703,13 @@ int lxcfs_readlink(const char *path, char *buf, size_t size)
636
703
return ret ;
637
704
}
638
705
706
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 ) {
707
+ up_users ();
708
+ ret = do_lxcfsctl_readlink (path , buf , size );
709
+ down_users ();
710
+ return ret ;
711
+ }
712
+
639
713
return - EINVAL ;
640
714
}
641
715
@@ -672,6 +746,13 @@ static int lxcfs_release(const char *path, struct fuse_file_info *fi)
672
746
return ret ;
673
747
}
674
748
749
+ if (LXCFS_TYPE_LXCFS (type )) {
750
+ up_users ();
751
+ ret = do_lxcfsctl_release (path , fi );
752
+ down_users ();
753
+ return ret ;
754
+ }
755
+
675
756
lxcfs_error ("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64 ,
676
757
path , type , fi -> fh );
677
758
@@ -718,6 +799,9 @@ int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
718
799
if (strncmp (path , "/sys" , 4 ) == 0 )
719
800
return - EPERM ;
720
801
802
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
803
+ return - EPERM ;
804
+
721
805
return - ENOENT ;
722
806
}
723
807
@@ -738,6 +822,9 @@ int lxcfs_truncate(const char *path, off_t newsize)
738
822
if (strncmp (path , "/sys" , 4 ) == 0 )
739
823
return 0 ;
740
824
825
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
826
+ return 0 ;
827
+
741
828
return - EPERM ;
742
829
}
743
830
@@ -776,6 +863,9 @@ int lxcfs_chmod(const char *path, mode_t mode)
776
863
if (strncmp (path , "/sys" , 4 ) == 0 )
777
864
return - EPERM ;
778
865
866
+ if (strncmp (path , "/lxcfs" , 6 ) == 0 )
867
+ return - EPERM ;
868
+
779
869
return - ENOENT ;
780
870
}
781
871
0 commit comments