1 /******************************************************************************
2  *
3  * Copyright (c) 2009 Citrix Systems, Inc. (Grzegorz Milos)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef __SHM_H__
19 #define __SHM_H__
20 
21 #include <pthread.h>
22 #include <unistd.h>
23 
24 #define MAX_NAME_LEN  1000
25 
26 typedef struct vbd_image_info {
27     char     file[MAX_NAME_LEN];
28     int      ref_cnt;
29     uint16_t next;
30     uint16_t prev;
31 } vbd_image_info_t;
32 
33 #define MAX_NR_VBD_IMAGES   4096
34 
35 typedef struct shared_memshr_info {
36     unsigned long    magic;
37     pthread_mutex_t  lock;
38     int              fgprtshr_hash_inited;
39     int              blockshr_hash_inited;
40     vbd_image_info_t vbd_images[MAX_NR_VBD_IMAGES];
41 } shared_memshr_info_t;
42 
43 shared_memshr_info_t * shm_shared_info_open(int unlink);
44 struct fgprtshr_hash * shm_fgprtshr_hash_open(int unlink);
45 struct blockshr_hash * shm_blockshr_hash_open(int unlink);
46 uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs);
47 void     shm_vbd_image_put(uint16_t memshr_id, vbd_image_info_t *vbd_imgs);
48 
49 #endif /* __SHM_H__ */
50