Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any "key-value" pair like data structure in linux kernel?

For example,I want to store Pid to Name mapping in some data structure. So that, we can quickly check if some given pid is already stored or not. Can you suggest some data structure in linux kernel for that ?

like image 295
A-B Avatar asked Oct 20 '22 14:10

A-B


1 Answers

There is map data structure in kernel, but it is not general purpose map. It maps identification number (UID) to a pointer. This is how you define it for example :

  struct idr map;
  idr_init(&map);

and then you use idr_get_new ( struct idr * idp,void * ptr,int * id); function to insert new element into the map

like image 188
Dabo Avatar answered Oct 22 '22 04:10

Dabo