From dc45e5b846a6457bc1de8d02ba542936c4ba1cfa Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Thu, 9 Sep 2004 01:23:27 +0000 Subject: [PATCH] Add/document autoreq_getxid(3), which gets the autofs request transaction id from the request, this is useful for debugging. Fix the autoh_freeall(3) function to properly free the array of auto handles. Before it was freeing individual members of the list OK, however it was then advancing the pointer and freeing the wrong data for the whole list. --- lib/libautofs/libautofs.3 | 6 ++++++ lib/libautofs/libautofs.c | 16 +++++++++++++--- lib/libautofs/libautofs.h | 5 +++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/libautofs/libautofs.3 b/lib/libautofs/libautofs.3 index 784813ed64d..fd9f1c304c4 100644 --- a/lib/libautofs/libautofs.3 +++ b/lib/libautofs/libautofs.3 @@ -63,6 +63,8 @@ .Ft void .Fn autoreq_getoffset "autoreq_t req" "off_t *offp" .Ft void +.Fn autoreq_getxid "autoreq_t req" "int *xidp" +.Ft void .Fn autoreq_setino "autoreq_t req" "autoino_t ino" .Ft void .Fn autoreq_seterrno "autoreq_t req" "int errno" @@ -176,6 +178,10 @@ return the auxilliray data associated with the request return the offset request associated with the request .Fa req . (used for readdir request) +.It Fn autoreq_getxid +return the transaction id associated with an autofs request, these +are unique per mount point, but not system wide. They can be used +for debugging to ensure requests are being accepted by the kernel. .El .Pp The following functions allow one to set the response sent to diff --git a/lib/libautofs/libautofs.c b/lib/libautofs/libautofs.c index a47535a3226..459b32d2048 100644 --- a/lib/libautofs/libautofs.c +++ b/lib/libautofs/libautofs.c @@ -206,10 +206,13 @@ err: void autoh_freeall(autoh_t *ah) { + autoh_t *ahp; - while (*ah != NULL) { - autoh_free(*ah); - ah++; + ahp = ah; + + while (*ahp != NULL) { + autoh_free(*ahp); + ahp++; } safe_free(ah); } @@ -396,6 +399,13 @@ autoreq_getoffset(autoreq_t req, off_t *offp) *offp = req->au_offset - AUTOFS_USEROFF; } +void +autoreq_getxid(autoreq_t req, int *xid) +{ + + *xid = req->au_xid; +} + /* toggle by path. args = handle, AUTO_?, pid (-1 to disable), path. */ int autoh_togglepath(autoh_t ah, int op, pid_t pid, const char *path) diff --git a/lib/libautofs/libautofs.h b/lib/libautofs/libautofs.h index 5fb29a962f3..f391bad3096 100644 --- a/lib/libautofs/libautofs.h +++ b/lib/libautofs/libautofs.h @@ -92,8 +92,9 @@ autoino_t autoreq_getdirino(autoreq_t); void autoreq_seterrno(autoreq_t, int); void autoreq_setaux(autoreq_t, void *, size_t); void autoreq_getaux(autoreq_t, void **, size_t *); -void autoreq_seteof(autoreq_t req, int eof); -void autoreq_getoffset(autoreq_t req, off_t *offp); +void autoreq_seteof(autoreq_t, int); +void autoreq_getoffset(autoreq_t, off_t *); +void autoreq_getxid(autoreq_t, int *); /* toggle by path. args = handle, AUTO_?, pid (-1 to disable), path. */ int autoh_togglepath(autoh_t, int, pid_t, const char *);