summaryrefslogtreecommitdiff
path: root/src/lib/shm_rdrbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/shm_rdrbuff.c')
-rw-r--r--src/lib/shm_rdrbuff.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c
index b0d295d9..7c4927fc 100644
--- a/src/lib/shm_rdrbuff.c
+++ b/src/lib/shm_rdrbuff.c
@@ -139,13 +139,13 @@ static char * rdrb_filename(enum qos_cube qos)
++chars;
} while (qm > 0);
- str = malloc(strlen(SHM_RDRB_PREFIX) + chars + 2);
+ str = malloc(strlen(SHM_RDRB_PREFIX) + chars + 1);
if (str == NULL) {
LOG_ERR("Failed to create shm_rdrbuff: Out of Memory.");
return NULL;
}
- sprintf(str, "%s.%d", SHM_RDRB_PREFIX, (int) qos);
+ sprintf(str, "%s%d", SHM_RDRB_PREFIX, (int) qos);
return str;
}
@@ -154,6 +154,7 @@ static char * rdrb_filename(enum qos_cube qos)
struct shm_rdrbuff * shm_rdrbuff_create()
{
struct shm_rdrbuff * rdrb;
+ mode_t mask;
int shm_fd;
uint8_t * shm_base;
pthread_mutexattr_t mattr;
@@ -171,6 +172,8 @@ struct shm_rdrbuff * shm_rdrbuff_create()
return NULL;
}
+ mask = umask(0);
+
shm_fd = shm_open(shm_rdrb_fn, O_CREAT | O_EXCL | O_RDWR, 0666);
if (shm_fd == -1) {
LOG_DBGF("Failed creating shared memory map.");
@@ -179,12 +182,7 @@ struct shm_rdrbuff * shm_rdrbuff_create()
return NULL;
}
- if (fchmod(shm_fd, 0666)) {
- LOG_DBGF("Failed to chmod shared memory map.");
- free(shm_rdrb_fn);
- free(rdrb);
- return NULL;
- }
+ umask(mask);
if (ftruncate(shm_fd, SHM_FILE_SIZE - 1) < 0) {
LOG_DBGF("Failed to extend shared memory map.");
@@ -469,7 +467,7 @@ ssize_t shm_rdrbuff_write(struct shm_rdrbuff * rdrb,
#ifndef SHM_RDRB_MULTI_BLOCK
if (sz > SHM_RDRB_BLOCK_SIZE) {
- LOG_DBGF("Multi-block SDU's disabled. Dropping.");
+ LOG_DBGF("Multi-block SDUs disabled. Dropping.");
return -1;
}
#endif
@@ -558,7 +556,7 @@ ssize_t shm_rdrbuff_write_b(struct shm_rdrbuff * rdrb,
#ifndef SHM_RDRB_MULTI_BLOCK
if (sz > SHM_RDRB_BLOCK_SIZE) {
- LOG_DBGF("Multi-block SDU's disabled. Dropping.");
+ LOG_DBGF("Multi-block SDUs disabled. Dropping.");
return -1;
}
#endif