*/
#define _GNU_SOURCE
+#include <unistd.h>
#include <urcu/arch.h>
#include <limits.h>
unsigned long subbuf_size, mmap_offset = 0;
unsigned long num_subbuf_alloc;
unsigned long i;
+ long page_size;
subbuf_size = chanb->subbuf_size;
num_subbuf_alloc = num_subbuf;
if (extra_reader_sb)
num_subbuf_alloc++;
+ page_size = sysconf(_SC_PAGE_SIZE);
+ if (page_size <= 0) {
+ goto page_size_error;
+ }
+
align_shm(shmobj, __alignof__(struct lttng_ust_lib_ring_buffer_backend_pages_shmp));
set_shmp(bufb->array, zalloc_shm(shmobj,
sizeof(struct lttng_ust_lib_ring_buffer_backend_pages_shmp) * num_subbuf_alloc));
/*
* This is the largest element (the buffer pages) which needs to
- * be aligned on PAGE_SIZE.
+ * be aligned on page size.
*/
- align_shm(shmobj, PAGE_SIZE);
+ align_shm(shmobj, page_size);
set_shmp(bufb->memory_map, zalloc_shm(shmobj,
subbuf_size * num_subbuf_alloc));
if (caa_unlikely(!shmp(handle, bufb->memory_map)))
memory_map_error:
/* bufb->array will be freed by shm teardown */
array_error:
+page_size_error:
return -ENOMEM;
}
* @name: channel name
* @config: client ring buffer configuration
* @parent: dentry of parent directory, %NULL for root directory
- * @subbuf_size: size of sub-buffers (> PAGE_SIZE, power of 2)
+ * @subbuf_size: size of sub-buffers (> page size, power of 2)
* @num_subbuf: number of sub-buffers (power of 2)
* @lttng_ust_shm_handle: shared memory handle
*
unsigned int i;
int ret;
size_t shmsize = 0, num_subbuf_alloc;
+ long page_size;
if (!name)
return -EPERM;
+ page_size = sysconf(_SC_PAGE_SIZE);
+ if (page_size <= 0) {
+ return -ENOMEM;
+ }
/* Check that the subbuffer size is larger than a page. */
- if (subbuf_size < PAGE_SIZE)
+ if (subbuf_size < page_size)
return -EINVAL;
/*
num_subbuf_alloc = num_subbuf + 1;
shmsize += offset_align(shmsize, __alignof__(struct lttng_ust_lib_ring_buffer_backend_pages_shmp));
shmsize += sizeof(struct lttng_ust_lib_ring_buffer_backend_pages_shmp) * num_subbuf_alloc;
- shmsize += offset_align(shmsize, PAGE_SIZE);
+ shmsize += offset_align(shmsize, page_size);
shmsize += subbuf_size * num_subbuf_alloc;
shmsize += offset_align(shmsize, __alignof__(struct lttng_ust_lib_ring_buffer_backend_pages));
shmsize += sizeof(struct lttng_ust_lib_ring_buffer_backend_pages) * num_subbuf_alloc;
int ret;
page_size = sysconf(_SC_PAGE_SIZE);
- if (page_size < 0) {
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ perror("Error in sysconf(_SC_PAGE_SIZE)");
goto error;
}
wait_shm_mmap = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
const char *outputpath;
const char **event_names;
unsigned int nr_events;
+ long page_size;
if (argc < 2) {
printf("Usage:\n");
return -1;
}
+ page_size = sysconf(_SC_PAGE_SIZE);
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ perror("Error in sysconf(_SC_PAGE_SIZE)");
+ return -1;
+ }
+
if (geteuid() == 0) {
ret = mkdir(LTTNG_RUNDIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (ret && errno != EEXIST) {
return -1;
}
wait_shm_fd = get_wait_shm(DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH,
- sysconf(_SC_PAGE_SIZE), 1);
+ page_size, 1);
if (wait_shm_fd < 0) {
perror("global wait shm error");
return -1;
snprintf(local_apps_wait_shm_path, PATH_MAX,
DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
wait_shm_fd = get_wait_shm(local_apps_wait_shm_path,
- sysconf(_SC_PAGE_SIZE), 0);
+ page_size, 0);
if (wait_shm_fd < 0) {
perror("local wait shm error");
return -1;
int ret;
page_size = sysconf(_SC_PAGE_SIZE);
- if (page_size < 0) {
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ perror("Error in sysconf(_SC_PAGE_SIZE)");
goto error;
}
wait_shm_mmap = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
int ret, wait_shm_fd;
struct sigaction act;
mode_t old_umask = 0;
+ long page_size;
set_ulimit();
return -1;
}
+ page_size = sysconf(_SC_PAGE_SIZE);
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ perror("Error in sysconf(_SC_PAGE_SIZE)");
+ return -1;
+ }
+
if (geteuid() == 0) {
ret = mkdir(LTTNG_RUNDIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (ret && errno != EEXIST) {
return -1;
}
wait_shm_fd = get_wait_shm(DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH,
- sysconf(_SC_PAGE_SIZE), 1);
+ page_size, 1);
if (wait_shm_fd < 0) {
perror("global wait shm error");
return -1;
snprintf(local_apps_wait_shm_path, PATH_MAX,
DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
wait_shm_fd = get_wait_shm(local_apps_wait_shm_path,
- sysconf(_SC_PAGE_SIZE), 0);
+ page_size, 0);
if (wait_shm_fd < 0) {
perror("local wait shm error");
return -1;