Skip to content

Commit 3322ab4

Browse files
committed
src/bindings: make struct pidns_store versionized
It's necessary as we want to be able to easily extend it and use live reloads update mechanism. This change does not break compatibility, because struct pidns_store lifetime is limited to liblxcfs lifetime. But we'll make pidns_store lifetime bigger that's why we need to start versionizing it. Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
1 parent 73c6029 commit 3322ab4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/bindings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ static void save_initpid(ino_t pidns_inode, pid_t pid)
320320

321321
ino_hash = HASH(pidns_inode);
322322
*entry = (struct pidns_store){
323+
.version = 0,
323324
.ino = pidns_inode,
324325
.initpid = pid,
325326
.ctime = st.st_ctime,

src/bindings.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,18 @@ struct file_info {
123123
* cached initpid.
124124
*/
125125
struct pidns_store {
126+
/* increase version if the structure was changed */
127+
__u16 version;
128+
129+
/* hash table key */
126130
ino_t ino; /* inode number for /proc/$pid/ns/pid */
127-
pid_t initpid; /* the pid of nit in that ns */
131+
132+
/* next entry in hash table's bucket */
133+
struct pidns_store *next;
134+
135+
pid_t initpid; /* the pid of init in that ns */
128136
int init_pidfd;
129137
int64_t ctime; /* the time at which /proc/$initpid was created */
130-
struct pidns_store *next;
131138
int64_t lastcheck;
132139
};
133140

0 commit comments

Comments
 (0)