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 @@ -380,7 +380,7 @@ static void save_initpid(ino_t pidns_inode, pid_t pid)
380
380
381
381
ino_hash = HASH (pidns_inode );
382
382
* entry = (struct pidns_store ){
383
- .version = 1 ,
383
+ .version = 2 ,
384
384
.ino = pidns_inode ,
385
385
.initpid = pid ,
386
386
.ctime = st .st_ctime ,
@@ -661,6 +661,55 @@ pid_t lookup_initpid_in_store(pid_t pid)
661
661
return hashed_pid ;
662
662
}
663
663
664
+ bool check_set_lxcfs_feature (pid_t pid , enum lxcfs_feature_op op , __u64 feature )
665
+ {
666
+ bool ret = false;
667
+ struct pidns_store * entry ;
668
+ ino_t pidns_ino ;
669
+
670
+ pidns_ino = get_pidns_ino (pid );
671
+ if (!pidns_ino )
672
+ return ret ;
673
+
674
+ store_lock ();
675
+
676
+ entry = lookup_verify_pidns_entry (pidns_ino );
677
+ if (!entry )
678
+ goto out ;
679
+
680
+ if (entry -> version < 2 )
681
+ goto out ;
682
+
683
+ switch (op ) {
684
+ case LXCFS_FEATURE_CHECK :
685
+ ret = entry -> features & feature ;
686
+
687
+ break ;
688
+ case LXCFS_FEATURE_SET :
689
+ entry -> features |= feature ;
690
+
691
+ /*
692
+ * As we have enabled feature, this entry
693
+ * must be kept across lxcfs live reloads.
694
+ */
695
+ entry -> keep_on_reload = true;
696
+
697
+ ret = true;
698
+
699
+ break ;
700
+ case LXCFS_FEATURE_CLEAR :
701
+ entry -> features &= ~feature ;
702
+ ret = true;
703
+
704
+ break ;
705
+ }
706
+
707
+ out :
708
+ store_unlock ();
709
+
710
+ return ret ;
711
+ }
712
+
664
713
/*
665
714
* Functions needed to setup cgroups in the __constructor__.
666
715
*/
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ struct file_info {
104
104
int cached ;
105
105
};
106
106
107
+ enum lxcfs_feature_op {
108
+ LXCFS_FEATURE_CHECK ,
109
+ LXCFS_FEATURE_SET ,
110
+ LXCFS_FEATURE_CLEAR ,
111
+ };
112
+
107
113
/*
108
114
* A table caching which pid is init for a pid namespace.
109
115
* When looking up which pid is init for $qpid, we first
@@ -135,6 +141,9 @@ struct pidns_store {
135
141
136
142
/* Do not free on liblxcfs reload (contains useful persistent data) */
137
143
bool keep_on_reload ;
144
+
145
+ /* bit mask for per-instance configuration options (on/off) */
146
+ __u64 features ;
138
147
};
139
148
140
149
/* lol - look at how they are allocated in the kernel */
@@ -174,6 +183,7 @@ typedef int (*pidns_store_iter_func_t) (struct pidns_store *cur, void *data);
174
183
175
184
extern int iter_initpid_store (pidns_store_iter_func_t f , void * data );
176
185
extern pid_t lookup_initpid_in_store (pid_t qpid );
186
+ extern bool check_set_lxcfs_feature (pid_t pid , enum lxcfs_feature_op op , __u64 feature );
177
187
extern void prune_init_slice (char * cg );
178
188
extern bool supports_pidfd (void );
179
189
extern bool liblxcfs_functional (void );
You can’t perform that action at this time.
0 commit comments