diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-04-16 12:12:27 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-04-16 12:12:27 +0000 |
commit | 04a7b2d37985e5ded07762fa186128aa3185b37c (patch) | |
tree | 790777ea9dc25e1ddaab554028cd53d3ea71c063 | |
parent | a5028ef44ecc830d8e8984fab2ad3c77c66a0092 (diff) | |
download | FreeBSD-src-04a7b2d37985e5ded07762fa186128aa3185b37c.zip FreeBSD-src-04a7b2d37985e5ded07762fa186128aa3185b37c.tar.gz |
Modify the alq(9) alq_open() API to accept a file creation mode, rather
than defaulting the cmode argument to vn_open() to 0. Supply a default
argument of ALQ_DEFAULT_CMODE (0600) in current callers.
Discussed with/pointed out by: hmp
Reveiwed by: jeff, hmp
MFC after: 3 days
-rw-r--r-- | share/man/man9/alq.9 | 17 | ||||
-rw-r--r-- | sys/contrib/dev/ath/freebsd/ah_osdep.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_alq.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_ktr.c | 4 | ||||
-rw-r--r-- | sys/sys/alq.h | 9 |
5 files changed, 28 insertions, 10 deletions
diff --git a/share/man/man9/alq.9 b/share/man/man9/alq.9 index fc2b618..ec6ef26 100644 --- a/share/man/man9/alq.9 +++ b/share/man/man9/alq.9 @@ -44,6 +44,7 @@ .Fa "struct alq **app" .Fa "const char *file" .Fa "struct ucred *cred" +.Fa "int cmode" .Fa "int size" .Fa "int count" .Fc @@ -98,10 +99,22 @@ The function creates a new logging queue. The .Fa file -argument is the name of the file to open for logging. +argument is the name of the file to open for logging; if the file does not +yet exist, +.Fn alq_open +will attempt to create it. +The +.Fa cmode +argument will be passed to +.Fn vn_open +as the requested creation mode, to be used if the file will be created by +.Fn alq_open . +Consumers of this API may wish to pass +.Dv ALQ_DEFAULT_CMODE , +a default creation mode suitable for most applications. The argument .Fa cred -specifies the credentials to use when opening the file. +specifies the credentials to use when opening and performing I/O on the file. The size of each entry in the queue is determined by .Fa size . The diff --git a/sys/contrib/dev/ath/freebsd/ah_osdep.c b/sys/contrib/dev/ath/freebsd/ah_osdep.c index 56756b9..1dc7460 100644 --- a/sys/contrib/dev/ath/freebsd/ah_osdep.c +++ b/sys/contrib/dev/ath/freebsd/ah_osdep.c @@ -185,7 +185,7 @@ ath_hal_setlogging(int enable) error = suser(curthread); if (error == 0) { error = alq_open(&ath_hal_alq, ath_hal_logfile, - curthread->td_ucred, + curthread->td_ucred, ALQ_DEFAULT_CMODE, sizeof (struct athregrec), ath_hal_alq_qsize); ath_hal_alq_lost = 0; ath_hal_alq_emitdev = 1; diff --git a/sys/kern/kern_alq.c b/sys/kern/kern_alq.c index c7b7125..3617afe 100644 --- a/sys/kern/kern_alq.c +++ b/sys/kern/kern_alq.c @@ -334,8 +334,8 @@ SYSINIT(ald, SI_SUB_LOCK, SI_ORDER_ANY, ald_startup, NULL) * Create the queue data structure, allocate the buffer, and open the file. */ int -alq_open(struct alq **alqp, const char *file, struct ucred *cred, int size, - int count) +alq_open(struct alq **alqp, const char *file, struct ucred *cred, int cmode, + int size, int count) { struct thread *td; struct nameidata nd; @@ -353,7 +353,7 @@ alq_open(struct alq **alqp, const char *file, struct ucred *cred, int size, NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td); flags = FWRITE | O_NOFOLLOW | O_CREAT; - error = vn_open_cred(&nd, &flags, 0, cred, -1); + error = vn_open_cred(&nd, &flags, cmode, cred, -1); if (error) return (error); diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index bd25e36..e23d972 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -145,8 +145,8 @@ sysctl_debug_ktr_alq_enable(SYSCTL_HANDLER_ARGS) if (error) return (error); error = alq_open(&ktr_alq, (const char *)ktr_alq_file, - req->td->td_ucred, sizeof(struct ktr_entry), - ktr_alq_depth); + req->td->td_ucred, ALQ_DEFAULT_CMODE, + sizeof(struct ktr_entry), ktr_alq_depth); if (error == 0) { ktr_mask &= ~KTR_ALQ_MASK; ktr_alq_cnt = 0; diff --git a/sys/sys/alq.h b/sys/sys/alq.h index cd8e8d3..bc4961e 100644 --- a/sys/sys/alq.h +++ b/sys/sys/alq.h @@ -53,12 +53,17 @@ struct ale { #define ALQ_NOWAIT 0x0001 #define ALQ_WAITOK 0x0002 +/* Suggested mode for file creation. */ +#define ALQ_DEFAULT_CMODE 0600 + /* * alq_open: Creates a new queue * * Arguments: * alq Storage for a pointer to the newly created queue. * file The filename to open for logging. + * cred Credential to authorize open and I/O with. + * cmode Creation mode for file, if new. * size The size of each entry in the queue. * count The number of items in the buffer, this should be large enough * to store items over the period of a disk write. @@ -66,8 +71,8 @@ struct ale { * error from open or 0 on success */ struct ucred; -int alq_open(struct alq **, const char *file, struct ucred *cred, int size, - int count); +int alq_open(struct alq **, const char *file, struct ucred *cred, int cmode, + int size, int count); /* * alq_write: Write data into the queue |