32 return SSVM_API_ERROR_NO_SIZE;
38 ssvm_filename =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
40 unlink ((
char *) ssvm_filename);
44 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR | O_CREAT | O_EXCL, 0777);
49 return SSVM_API_ERROR_CREATE_FAILURE;
52 if (fchmod (ssvm_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0)
54 if (fchown (ssvm_fd, smr->
uid, smr->
gid) < 0)
57 if (lseek (ssvm_fd, ssvm->
ssvm_size, SEEK_SET) < 0)
61 return SSVM_API_ERROR_SET_SIZE;
64 if (write (ssvm_fd, &junk, 1) != 1)
68 return SSVM_API_ERROR_SET_SIZE;
85 if (ssvm->
sh == MAP_FAILED)
89 return SSVM_API_ERROR_MMAP;
124 while (timeout_in_seconds-- > 0)
127 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR, 0777);
133 if (fstat (ssvm_fd, &stat) < 0)
139 if (stat.st_size > 0)
143 return SSVM_API_ERROR_SLAVE_TIMEOUT;
146 sh = (
void *) mmap (0,
MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
148 if (sh == MAP_FAILED)
152 return SSVM_API_ERROR_MMAP;
155 while (timeout_in_seconds-- > 0)
163 return SSVM_API_ERROR_SLAVE_TIMEOUT;
171 PROT_READ | PROT_WRITE,
172 MAP_SHARED | MAP_FIXED, ssvm_fd, 0);
174 if (sh == MAP_FAILED)
178 return SSVM_API_ERROR_MMAP;
189 fn =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
192 clib_warning (
"[%d] unlinking ssvm (%s) backing file '%s'", getpid (),
196 if (unlink ((
char *) fn) < 0)
svm_region_t * svm_get_root_rp(void)
#define vec_c_string_is_terminated(V)
Test whether a vector is a NULL terminated c-string.
int ssvm_master_init(ssvm_private_t *ssvm, u32 master_index)
static u64 clib_cpu_time_now(void)
ssvm_shared_header_t * sh
#define MHEAP_FLAG_THREAD_SAFE
void ssvm_delete(ssvm_private_t *ssvm)
#define MHEAP_FLAG_DISABLE_VM
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
static void ssvm_pop_heap(void *oldheap)
static uword pointer_to_uword(const void *p)
int ssvm_slave_init(ssvm_private_t *ssvm, int timeout_in_seconds)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
#define clib_unix_warning(format, args...)