Add perm option to SHM driver

This commit is contained in:
Miroslav Lichvar 2010-01-28 10:03:54 +01:00
parent a0e1154bfb
commit f261251a9b
2 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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;