From: Klas Lindfors Date: Sun, 8 May 2005 07:16:45 +0000 (+0000) Subject: export-calleraccess-via-pioctl-20050508 X-Git-Tag: openafs-devel-1_5_0~575 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=5afb5d6246d34948d15e93d1af9c2370d26c9f3a export-calleraccess-via-pioctl-20050508 FIXES 18442 provide pioctl to get CallerAccess bits --- diff --git a/src/afs/afs.h b/src/afs/afs.h index 4818d6e..0205b75 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -784,6 +784,13 @@ struct vcxstat { afs_uint32 states; }; +struct vcxstat2 { + afs_int32 callerAccess; + afs_int32 cbExpires; + afs_int32 anyAccess; + char mvstat; +}; + struct sbstruct { int sb_thisfile; int sb_default; diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index e6d734c..18e02d5 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -71,6 +71,7 @@ DECL_PIOCTL(PGetCellStatus); DECL_PIOCTL(PSetCellStatus); DECL_PIOCTL(PFlushVolumeData); DECL_PIOCTL(PGetVnodeXStatus); +DECL_PIOCTL(PGetVnodeXStatus2); DECL_PIOCTL(PSetSysName); DECL_PIOCTL(PSetSPrefs); DECL_PIOCTL(PSetSPrefs33); @@ -183,6 +184,7 @@ static int (*(VpioctlSw[])) () = { PPrefetchFromTape, /* 66 -- MR-AFS: prefetch file from tape */ PResidencyCmd, /* 67 -- MR-AFS: generic commnd interface */ PBogus, /* 68 -- arla: fetch stats */ + PGetVnodeXStatus2, /* 69 - get caller access and some vcache status */ }; static int (*(CpioctlSw[])) () = { @@ -2642,6 +2644,8 @@ DECL_PIOCTL(PGetVnodeXStatus) mode = PRSFS_READ; if (!afs_AccessOK(avc, mode, areq, CHECK_MODE_BITS)) return EACCES; + + memset(&stat, 0, sizeof(struct vcxstat)); stat.fid = avc->fid; hset32(stat.DataVersion, hgetlo(avc->m.DataVersion)); stat.lock = avc->lock; @@ -2672,6 +2676,36 @@ DECL_PIOCTL(PGetVnodeXStatus) } +DECL_PIOCTL(PGetVnodeXStatus2) +{ + register afs_int32 code; + struct vcxstat2 stat; + afs_int32 mode; + + if (!avc) + return EINVAL; + code = afs_VerifyVCache(avc, areq); + if (code) + return code; + if (vType(avc) == VDIR) + mode = PRSFS_LOOKUP; + else + mode = PRSFS_READ; + if (!afs_AccessOK(avc, mode, areq, CHECK_MODE_BITS)) + return EACCES; + + memset(&stat, 0, sizeof(struct vcxstat2)); + + stat.cbExpires = avc->cbExpires; + stat.anyAccess = avc->anyAccess; + stat.mvstat = avc->mvstat; + stat.callerAccess = afs_GetAccessBits(avc, ~0, areq); + + memcpy(aout, (char *)&stat, sizeof(struct vcxstat2)); + *aoutSize = sizeof(struct vcxstat2); + return 0; +} + /* We require root for local sysname changes, but not for remote */ /* (since we don't really believe remote uids anyway) */ /* outname[] shouldn't really be needed- this is left as an excercise */ diff --git a/src/config/venus.h b/src/config/venus.h index f538026..eb5e5b8 100644 --- a/src/config/venus.h +++ b/src/config/venus.h @@ -175,6 +175,7 @@ struct cm_initparams { #define VIOC_PREFETCHTAPE _VICEIOCTL(66) /* MR-AFS prefetch from tape */ #define VIOC_RESIDENCY_CMD _VICEIOCTL(67) /* generic MR-AFS cmds */ #define VIOC_STATISTICS _VICEIOCTL(68) /* arla: fetch statistics */ +#define VIOC_GETVCXSTATUS2 _VICEIOCTL(69) /* vcache statistics */ /* Coordinated 'C' pioctl's */ #define VIOC_NEWALIAS _CVICEIOCTL(1) /* create new cell alias */ diff --git a/src/venus/fs.c b/src/venus/fs.c index d7ba182..2be9d24 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -112,6 +112,13 @@ struct AclEntry { afs_int32 rights; }; +struct vcxstat2 { + afs_int32 callerAccess; + afs_int32 cbExpires; + afs_int32 anyAccess; + char mvstat; +}; + static void ZapAcl(acl) struct Acl *acl; @@ -1189,6 +1196,33 @@ ListACLCmd(struct cmd_syndesc *as, char *arock) } static int +GetCallerAccess(struct cmd_syndesc *as, char *arock) +{ + struct cmd_item *ti; + int error = 0; + + SetDotDefault(&as->parms[0].items); + for (ti = as->parms[0].items; ti; ti = ti->next) { + afs_int32 code; + struct ViceIoctl blob; + struct vcxstat2 stat; + blob.out_size = sizeof(struct vcxstat2); + blob.in_size = 0; + blob.out = &stat; + code = pioctl(ti->data, VIOC_GETVCXSTATUS2, &blob, 1); + if (code) { + Die(errno, ti->data); + error = 1; + continue; + } + printf("Callers access to %s is ", ti->data); + PRights(stat.callerAccess, 0); + printf("\n"); + } + return error; +} + +static int FlushVolumeCmd(struct cmd_syndesc *as, char *arock) { afs_int32 code; @@ -3172,6 +3206,11 @@ main(int argc, char **argv) cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl"); cmd_CreateAlias(ts, "la"); + ts = cmd_CreateSyntax("getcalleraccess", GetCallerAccess, 0, + "list callers access"); + cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path"); + cmd_CreateAlias(ts, "gca"); + ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list"); cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");