File tree Expand file tree Collapse file tree 2 files changed +60
-1
lines changed Expand file tree Collapse file tree 2 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ static void save_initpid(ino_t pidns_inode, pid_t pid)
362
362
363
363
ino_hash = HASH (pidns_inode );
364
364
* entry = (struct pidns_store ){
365
- .version = 1 ,
365
+ .version = 2 ,
366
366
.ino = pidns_inode ,
367
367
.initpid = pid ,
368
368
.ctime = st .st_ctime ,
@@ -643,6 +643,55 @@ pid_t lookup_initpid_in_store(pid_t pid)
643
643
return hashed_pid ;
644
644
}
645
645
646
+ bool check_set_lxcfs_feature (pid_t pid , enum lxcfs_feature_op op , __u64 feature )
647
+ {
648
+ bool ret = false;
649
+ struct pidns_store * entry ;
650
+ ino_t pidns_ino ;
651
+
652
+ pidns_ino = get_pidns_ino (pid );
653
+ if (!pidns_ino )
654
+ return ret ;
655
+
656
+ store_lock ();
657
+
658
+ entry = lookup_verify_pidns_entry (pidns_ino );
659
+ if (!entry )
660
+ goto out ;
661
+
662
+ if (entry -> version < 2 )
663
+ goto out ;
664
+
665
+ switch (op ) {
666
+ case LXCFS_FEATURE_CHECK :
667
+ ret = entry -> features & feature ;
668
+
669
+ break ;
670
+ case LXCFS_FEATURE_SET :
671
+ entry -> features |= feature ;
672
+
673
+ /*
674
+ * As we have enabled feature, this entry
675
+ * must be kept across lxcfs live reloads.
676
+ */
677
+ entry -> keep_on_reload = true;
678
+
679
+ ret = true;
680
+
681
+ break ;
682
+ case LXCFS_FEATURE_CLEAR :
683
+ entry -> features &= ~feature ;
684
+ ret = true;
685
+
686
+ break ;
687
+ }
688
+
689
+ out :
690
+ store_unlock ();
691
+
692
+ return ret ;
693
+ }
694
+
646
695
/*
647
696
* Functions needed to setup cgroups in the __constructor__.
648
697
*/
Original file line number Diff line number Diff line change @@ -108,6 +108,12 @@ struct file_info {
108
108
int cached ;
109
109
};
110
110
111
+ enum lxcfs_feature_op {
112
+ LXCFS_FEATURE_CHECK ,
113
+ LXCFS_FEATURE_SET ,
114
+ LXCFS_FEATURE_CLEAR ,
115
+ };
116
+
111
117
/*
112
118
* A table caching which pid is init for a pid namespace.
113
119
* When looking up which pid is init for $qpid, we first
@@ -139,6 +145,9 @@ struct pidns_store {
139
145
140
146
/* Do not free on liblxcfs reload (contains useful persistent data) */
141
147
bool keep_on_reload ;
148
+
149
+ /* bit mask for per-instance configuration options (on/off) */
150
+ __u64 features ;
142
151
};
143
152
144
153
/* lol - look at how they are allocated in the kernel */
@@ -176,6 +185,7 @@ typedef int (*pidns_store_iter_func_t) (struct pidns_store *cur, void *data);
176
185
177
186
extern int iter_initpid_store (pidns_store_iter_func_t f , void * data );
178
187
extern pid_t lookup_initpid_in_store (pid_t qpid );
188
+ extern bool check_set_lxcfs_feature (pid_t pid , enum lxcfs_feature_op op , __u64 feature );
179
189
extern void prune_init_slice (char * cg );
180
190
extern bool supports_pidfd (void );
181
191
extern bool liblxcfs_functional (void );
You can’t perform that action at this time.
0 commit comments