On Nov 3, 2014, at 9:54 AM, Benjamin Coddington <bcodding@xxxxxxxxxx> wrote: > Change the keyctl_invalidate call to use the syscall interface directly so > that when building with libkeyutils missing keyctl_invalidate the build succeeds. > Attempt to use _invalidate and fall back to _revoke if the current kernel is > missing _invalidate. > > Signed-off-by: Benjamin Coddington <bcodding@xxxxxxxxxx> > --- > utils/nfsidmap/nfsidmap.c | 15 +++++++++++---- > 1 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c > index e0d31e7..99ae07e 100644 > --- a/utils/nfsidmap/nfsidmap.c > +++ b/utils/nfsidmap/nfsidmap.c > @@ -209,10 +209,17 @@ static int key_invalidate(char *keystr, int keymask) > *(strchr(buf, ' ')) = '\0'; > sscanf(buf, "%x", &key); > > - if (keyctl_invalidate(key) < 0) { > - xlog_err("keyctl_invalidate(0x%x) failed: %m", key); > - fclose(fp); > - return 1; > +/* older libkeyutils compatibility */ > +#ifndef KEYCTL_INVALIDATE > +#define KEYCTL_INVALIDATE 21 /* invalidate a key */ > +#endif > + if (keyctl(KEYCTL_INVALIDATE, key) < 0 && errno == EOPNOTSUPP) { > + /* older kernel compatibility attempt: */ > + if (keyctl_revoke(key) < 0) { > + xlog_err("keyctl_invalidate(0x%x) failed: %m", key); > + fclose(fp); > + return 1; > + } Thanks, Ben. This logic handles and reports errors only from keyctl_revoke(). Can it be updated to report errors (other than EOPNOTSUPP) from either function, display the name of the keyctl function it tried to invoke, and close fp and exit appropriately? > } > > keymask &= ~mask; > -- > 1.7.1 > -- Chuck Lever chuck[dot]lever[at]oracle[dot]com -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html