* changed in future.
*/
int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
- const char *fname, int fd, const char *fmt,
+ const char *fname, int fd, const char *fmt, int perm,
snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
return -EINVAL;
}
if (fname) {
- fd = open(fname, O_WRONLY|O_CREAT, 0666);
+ fd = open(fname, O_WRONLY|O_CREAT, perm);
if (fd < 0) {
SYSERR("open %s failed", fname);
return -errno;
or
file INT # File descriptor number
[format STR] # File format (only "raw" at the moment)
+ [perm INT] # File permission (octal, default 0600)
}
\endcode
const char *fname = NULL;
const char *format = NULL;
long fd = -1;
+ int perm = 0600;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
}
continue;
}
+ if (strcmp(id, "perm") == 0) {
+ char *perm;
+ char *endp;
+ err = snd_config_get_ascii(n, &perm);
+ if (err < 0) {
+ SNDERR("The field perm must be a valid file permission");
+ return err;
+ }
+ if (isdigit(*perm) == 0) {
+ SNDERR("The field perm must be a valid file permission");
+ return -EINVAL;
+ }
+ perm = strtol(perm, &endp, 8);
+ continue;
+ }
SNDERR("Unknown field %s", id);
return -EINVAL;
}
snd_config_delete(sconf);
if (err < 0)
return err;
- err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1);
+ err = snd_pcm_file_open(pcmp, name, fname, fd, format, perm, spcm, 1);
if (err < 0)
snd_pcm_close(spcm);
return err;