#include "afs/kauth.h"
#include "afs/kautils.h"
#include "afs/afsutil.h"
+#include "afs/afs_bypasscache.h"
#include "rx/rx_globals.h"
#include "afsd/afsd.h"
{
struct usr_ucred *newcredp;
- newcredp = (struct usr_ucred *)afs_osi_Alloc(sizeof(struct usr_ucred));
+ newcredp = afs_osi_Alloc(sizeof(struct usr_ucred));
*newcredp = *credp;
newcredp->cr_ref = 1;
return newcredp;
{
struct usr_ucred *newcredp;
- newcredp = (struct usr_ucred *)afs_osi_Alloc(sizeof(struct usr_ucred));
+ newcredp = afs_osi_Alloc(sizeof(struct usr_ucred));
newcredp->cr_ref = 1;
return newcredp;
}
* allocate the data block, so pthread_finish can free the buffer
* when this thread terminates.
*/
- uptr =
- (struct usr_user *)malloc(sizeof(struct usr_user) +
- sizeof(struct usr_ucred));
+ uptr = malloc(sizeof(struct usr_user) + sizeof(struct usr_ucred));
usr_assert(uptr != NULL);
uptr->u_error = 0;
uptr->u_prio = 0;
{
struct usr_user *uptr;
int st;
- st = usr_getspecific(afs_global_u_key, (void **)&uptr);
+
+ st = usr_getspecific(afs_global_u_key, &uptr);
usr_assert(st == 0);
if (uptr == NULL) {
uafs_InitThread();
- st = usr_getspecific(afs_global_u_key, (void **)&uptr);
+ st = usr_getspecific(afs_global_u_key, &uptr);
usr_assert(st == 0);
usr_assert(uptr != NULL);
}
}
index = WAITHASH(x);
if (osi_waithash_avail == NULL) {
- waitp = (osi_wait_t *) afs_osi_Alloc(sizeof(osi_wait_t));
+ waitp = afs_osi_Alloc(sizeof(osi_wait_t));
usr_cond_init(&waitp->cond);
} else {
waitp = osi_waithash_avail;
}
index = WAITHASH((caddr_t) handle);
if (osi_waithash_avail == NULL) {
- waitp = (osi_wait_t *) afs_osi_Alloc(sizeof(osi_wait_t));
+ waitp = afs_osi_Alloc(sizeof(osi_wait_t));
usr_cond_init(&waitp->cond);
} else {
waitp = osi_waithash_avail;
AFS_ASSERT_GLOCK();
AFS_GUNLOCK();
- fp = (struct osi_file *)afs_osi_Alloc(sizeof(struct osi_file));
+ fp = afs_osi_Alloc(sizeof(struct osi_file));
usr_assert(fp != NULL);
usr_assert(ino->ufs);
*/
nextVc = NULL;
nextVp = NULL;
-#ifdef AFS_WEB_ENHANCEMENTS
if ((nextPathP != NULL && *nextPathP != '\0') || !no_eval_mtpt)
code = afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred, 0);
else
code =
afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred,
AFS_LOOKUP_NOEVAL);
-#else
- code = afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred, 0);
-#endif /* AFS_WEB_ENHANCEMENTS */
if (nextVc)
nextVp=AFSTOV(nextVc);
if (code != 0) {
}
int
+uafs_pread_nocache(int fd, char *buf, int len, off_t offset)
+{
+ int retval;
+ AFS_GLOCK();
+ retval = uafs_pread_nocache_r(fd, buf, len, offset);
+ AFS_GUNLOCK();
+ return retval;
+}
+
+int
+uafs_pread_nocache_r(int fd, char *buf, int len, off_t offset)
+{
+ int code;
+ struct iovec iov[1];
+ struct usr_vnode *fileP;
+ struct nocache_read_request *bparms;
+ struct usr_uio uio;
+
+ /*
+ * Make sure this is an open file
+ */
+ fileP = afs_FileTable[fd];
+ if (fileP == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+
+ /* these get freed in PrefetchNoCache, so... */
+ bparms = afs_osi_Alloc(sizeof(struct nocache_read_request));
+ bparms->areq = afs_osi_Alloc(sizeof(struct vrequest));
+
+ afs_InitReq(bparms->areq, get_user_struct()->u_cred);
+
+ bparms->auio = &uio;
+ bparms->offset = offset;
+ bparms->length = len;
+
+ /*
+ * set up the uio buffer
+ */
+ iov[0].iov_base = buf;
+ iov[0].iov_len = len;
+ uio.uio_iov = &iov[0];
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = offset;
+ uio.uio_segflg = 0;
+ uio.uio_fmode = FREAD;
+ uio.uio_resid = len;
+
+ /*
+ * do the read
+ */
+ code = afs_PrefetchNoCache(VTOAFS(fileP), get_user_struct()->u_cred,
+ bparms);
+
+ if (code) {
+ errno = code;
+ return -1;
+ }
+
+ afs_FileOffsets[fd] = uio.uio_offset;
+ return (len - uio.uio_resid);
+}
+
+int
uafs_pread(int fd, char *buf, int len, off_t offset)
{
int retval;
stats->st_atime = attrs.va_atime.tv_sec;
stats->st_mtime = attrs.va_mtime.tv_sec;
stats->st_ctime = attrs.va_ctime.tv_sec;
+ /* preserve dv if possible */
+#if defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
+ stats->st_atimespec.tv_nsec = attrs.va_atime.tv_usec * 1000;
+ stats->st_mtimespec.tv_nsec = attrs.va_mtime.tv_usec * 1000;
+ stats->st_ctimespec.tv_nsec = attrs.va_ctime.tv_usec * 1000;
+#elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC)
+ stats->st_atimensec = attrs.va_atime.tv_usec * 1000;
+ stats->st_mtimensec = attrs.va_mtime.tv_usec * 1000;
+ stats->st_ctimensec = attrs.va_ctime.tv_usec * 1000;
+#endif
stats->st_blksize = attrs.va_blocksize;
stats->st_blocks = attrs.va_blocks;
/*
* Set up the directory structures
*/
- dirp =
- (usr_DIR *) afs_osi_Alloc(sizeof(usr_DIR) + USR_DIRSIZE +
- sizeof(struct usr_dirent));
+ dirp = afs_osi_Alloc(sizeof(usr_DIR) + USR_DIRSIZE +
+ sizeof(struct usr_dirent));
usr_assert(dirp != NULL);
dirp->dd_buf = (char *)(dirp + 1);
dirp->dd_fd = fd;
}
/*
- * Do AFS authentication
- */
-int
-uafs_klog(char *user, char *cell, char *passwd, char **reason)
-{
- int code;
- afs_int32 password_expires = -1;
-
- usr_mutex_lock(&osi_authenticate_lock);
- code =
- ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION +
- KA_USERAUTH_DOSETPAG2, user, NULL, cell,
- passwd, 0, &password_expires, 0, reason);
- usr_mutex_unlock(&osi_authenticate_lock);
- return code;
-}
-
-int
-uafs_klog_r(char *user, char *cell, char *passwd, char **reason)
-{
- int retval;
- AFS_GUNLOCK();
- retval = uafs_klog(user, cell, passwd, reason);
- AFS_GLOCK();
- return retval;
-}
-
-/*
* Destroy AFS credentials from the kernel cache
*/
int
return NULL;
}
-#ifdef AFS_WEB_ENHANCEMENTS
-/*
- * uafs_klog_nopag
- * klog but don't allocate a new pag
- */
-int
-uafs_klog_nopag(char *user, char *cell, char *passwd, char **reason)
-{
- int code;
- afs_int32 password_expires = -1;
-
- usr_mutex_lock(&osi_authenticate_lock);
- code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION
- /*+KA_USERAUTH_DOSETPAG2 */ , user,
- NULL, cell, passwd, 0,
- &password_expires, 0, reason);
- usr_mutex_unlock(&osi_authenticate_lock);
- return code;
-}
-
/*
* uafs_getcellstatus
* get the cell status
{
int rc;
struct afs_ioctl iob;
- VolumeStatus *status;
- char buf[1024];
+ VolumeStatus status;
iob.in = 0;
iob.in_size = 0;
- iob.out = buf;
- iob.out_size = 1024;
+ iob.out = (char *)&status;
+ iob.out_size = sizeof status;
rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(4), (long)&iob,
0, 0);
return -1;
}
- status = (VolumeStatus *) buf;
- *BlocksInUse = status->BlocksInUse;
- *MaxQuota = status->MaxQuota;
+ *BlocksInUse = status.BlocksInUse;
+ *MaxQuota = status.MaxQuota;
return 0;
}
{
int rc;
struct afs_ioctl iob;
- VolumeStatus *status;
- char buf[1024];
+ VolumeStatus status = { 0 };
- iob.in = buf;
- iob.in_size = 1024;
+ iob.in = (char *)&status;
+ iob.in_size = sizeof status;
iob.out = 0;
iob.out_size = 0;
- memset(buf, 0, sizeof(VolumeStatus));
- status = (VolumeStatus *) buf;
- status->MaxQuota = MaxQuota;
- status->MinQuota = -1;
+ status.MaxQuota = MaxQuota;
+ status.MinQuota = -1;
rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(5), (long)&iob,
0, 0);
* Get a list of rights for the current user on path.
*/
int
+uafs_access(char *path, int flags)
+{
+ int code;
+ struct vnode *vp;
+ int fileMode = 0;
+
+ if (flags & R_OK) {
+ fileMode |= VREAD;
+ }
+ if (flags & W_OK) {
+ fileMode |= VWRITE;
+ }
+ if (flags & X_OK) {
+ fileMode |= VEXEC;
+ }
+
+ AFS_GLOCK();
+ code = uafs_LookupName(path, afs_CurrentDir, &vp, 1, 0);
+ if (code != 0) {
+ errno = code;
+ AFS_GUNLOCK();
+ return -1;
+ }
+
+ code = afs_access(VTOAFS(vp), fileMode, get_user_struct()->u_cred);
+ VN_RELE(vp);
+
+ if (code != 0)
+ errno = code;
+
+ AFS_GUNLOCK();
+ return code ? -1 : 0;
+}
+
+/*
+ * uafs_getRights
+ * Get a list of rights for the current user on path.
+ */
+int
uafs_getRights(char *path)
{
int code;
AFS_GUNLOCK();
return afs_rights;
}
-#endif /* AFS_WEB_ENHANCEMENTS */
-
#endif /* UKERNEL */