From f261251a9bcee1acc233e7fb96f841a60bb83b2a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 28 Jan 2010 10:03:54 +0100 Subject: [PATCH] Add perm option to SHM driver --- chrony.texi | 8 ++++++-- refclock_shm.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/chrony.texi b/chrony.texi index b0235cd..3f7c9b6 100644 --- a/chrony.texi +++ b/chrony.texi @@ -2242,14 +2242,18 @@ refclock PPS /dev/pps0 @item SHM NTP shared memory driver. The parameter is the number of the -shared memory segment that should be used to read timestamps, usually +shared memory segment that should be used for receiving timestamps, usually 0, 1, 2 or 3. For example: @example refclock SHM 1 poll 3 refid GPS1 @end example -Software that can be used as a source of timestamps includes +A driver option in form @code{:perm=NNN} can be appended to the +segment number to create the segment with permissions other than the +default @code{0600}. + +Software that can be used as a source of reference time includes @code{gpsd} and @code{shmpps}. @item SOCK Unix domain socket driver. The parameter is a path to the socket diff --git a/refclock_shm.c b/refclock_shm.c index b3b689b..ed0c3d0 100644 --- a/refclock_shm.c +++ b/refclock_shm.c @@ -56,12 +56,15 @@ struct shmTime { }; static int shm_initialise(RCL_Instance instance) { - int id, param; + int id, param, perm; + char *s; struct shmTime *shm; param = atoi(RCL_GetDriverParameter(instance)); + s = RCL_GetDriverOption(instance, "perm"); + perm = s ? strtol(s, NULL, 8) : 0600; - id = shmget(SHMKEY + param, sizeof (struct shmTime), IPC_CREAT | 0700); + id = shmget(SHMKEY + param, sizeof (struct shmTime), IPC_CREAT | perm); if (id == -1) { LOG_FATAL(LOGF_Refclock, "shmget() failed"); return 0;