}
int
+afs_osi_TimedSleep(void *event, afs_int32 ams, int aintok)
+{
+ return afs_osi_Wait(ams, event, aintok);
+}
+
+int
afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok)
{
int index;
AFS_ASSERT_GLOCK();
if (ino->ufs > n_osi_files) {
- u.u_error = ENOENT;
+ get_user_struct()->u_error = ENOENT;
return NULL;
}
usr_assert(fp != NULL);
fp->fd = open(osi_file_table[ino->ufs - 1].name, O_RDWR | O_CREAT, 0);
if (fp->fd < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
afs_osi_Free((char *)fp, sizeof(struct osi_file));
AFS_GLOCK();
return NULL;
}
rc = fstat(fp->fd, &st);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
afs_osi_Free((void *)fp, sizeof(struct osi_file));
AFS_GLOCK();
return NULL;
}
fp->size = st.st_size;
fp->offset = 0;
- fp->inum = ino->ufs;
fp->vnode = (struct usr_vnode *)fp;
AFS_GLOCK();
AFS_GUNLOCK();
rc = close(fp->fd);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
afs_osi_Free((void *)fp, sizeof(struct osi_file));
AFS_GLOCK();
return -1;
AFS_GUNLOCK();
rc = ftruncate(fp->fd, len);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
rc = lseek(fp->fd, fp->offset, SEEK_SET);
}
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
fp->offset = rc;
ret = read(fp->fd, buf, len);
if (ret < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
fp->offset += ret;
rc = fstat(fp->fd, &st);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
rc = lseek(fp->fd, fp->offset, SEEK_SET);
}
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
fp->offset = rc;
ret = write(fp->fd, buf, len);
if (ret < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
fp->offset += ret;
rc = fstat(fp->fd, &st);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
AFS_GUNLOCK();
rc = fstat(fp->fd, &st);
if (rc < 0) {
- u.u_error = errno;
+ get_user_struct()->u_error = errno;
AFS_GLOCK();
return -1;
}
uioP->uio_iov[0].iov_len);
}
if (rc < 0) {
- return u.u_error;
+ return get_user_struct()->u_error;
}
uioP->uio_resid -= rc;
}
void
-osi_FlushPages(register struct vcache *avc, AFS_UCRED *credp)
+osi_FlushPages(register struct vcache *avc, afs_ucred_t *credp)
{
ObtainSharedLock(&avc->lock, 555);
if ((hcmp((avc->f.m.DataVersion), (avc->mapDV)) <= 0)
for (currp = readdir(cdirp); currp; currp = readdir(cdirp)) {
if (afsd_debug) {
printf("%s: Current directory entry:\n", rn);
-#if defined(AFS_USR_DFBSD_ENV)
+#if defined(AFS_SGI62_ENV) || defined(AFS_USR_DARWIN100_ENV)
+ printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n",
+ currp->d_ino, currp->d_reclen, currp->d_name);
+#elif defined(AFS_USR_DFBSD_ENV)
printf("\tinode=%d, name='%s'\n", currp->d_ino,
currp->d_name);
#else
afs_osi_Alloc(sizeof(struct usr_ucred));
usr_assert(afs_global_ucredp != NULL);
afs_global_ucredp->cr_ref = 1;
- afs_global_ucredp->cr_uid = geteuid();
- afs_global_ucredp->cr_gid = getegid();
- afs_global_ucredp->cr_ruid = getuid();
- afs_global_ucredp->cr_rgid = getgid();
- afs_global_ucredp->cr_suid = afs_global_ucredp->cr_ruid;
- afs_global_ucredp->cr_sgid = afs_global_ucredp->cr_rgid;
+ afs_set_cr_uid(afs_global_ucredp, geteuid());
+ afs_set_cr_gid(afs_global_ucredp, getegid());
+ afs_set_cr_ruid(afs_global_ucredp, getuid());
+ afs_set_cr_rgid(afs_global_ucredp, getgid());
+ afs_global_ucredp->cr_suid = afs_cr_ruid(afs_global_ucredp);
+ afs_global_ucredp->cr_sgid = afs_cr_rgid(afs_global_ucredp);
st = getgroups(NGROUPS, &afs_global_ucredp->cr_groups[0]);
usr_assert(st >= 0);
afs_global_ucredp->cr_ngroups = (unsigned long)st;
afs_global_procp = (struct usr_proc *)
afs_osi_Alloc(sizeof(struct usr_proc));
usr_assert(afs_global_procp != NULL);
- afs_global_procp->p_pid = getpid();
+ afs_global_procp->p_pid = osi_getpid();
afs_global_procp->p_ppid = (pid_t) 1;
afs_global_procp->p_ucred = afs_global_ucredp;
return;
}
+int
+uafs_statvfs(struct statvfs *buf)
+{
+ int rc;
+
+ AFS_GLOCK();
+
+ rc = afs_statvfs(&afs_RootVfs, buf);
+
+ AFS_GUNLOCK();
+
+ if (rc) {
+ errno = rc;
+ return -1;
+ }
+
+ return 0;
+}
+
void
uafs_Shutdown(void)
{
/*
* AFS daemons run authenticated
*/
- u.u_viceid = getuid();
- crp = u.u_cred;
- crp->cr_uid = getuid();
- crp->cr_ruid = getuid();
+ get_user_struct()->u_viceid = getuid();
+ crp = get_user_struct()->u_cred;
+ afs_set_cr_uid(crp, getuid());
+ afs_set_cr_ruid(crp, getuid());
crp->cr_suid = getuid();
crp->cr_groups[0] = getgid();
crp->cr_ngroups = 1;
a.parm3 = param3;
a.parm4 = param4;
- u.u_error = 0;
- u.u_ap = (char *)&a;
+ get_user_struct()->u_error = 0;
+ get_user_struct()->u_ap = (char *)&a;
code = Afs_syscall();
return code;
/*
* We need execute permission to search a directory
*/
- code = afs_access(VTOAFS(vp), VEXEC, u.u_cred);
+ code = afs_access(VTOAFS(vp), VEXEC, get_user_struct()->u_cred);
if (code != 0) {
VN_RELE(vp);
afs_osi_Free(tmpPath, strlen(path) + 1);
nextVp = NULL;
#ifdef AFS_WEB_ENHANCEMENTS
if ((nextPathP != NULL && *nextPathP != '\0') || !no_eval_mtpt)
- code = afs_lookup(VTOAFS(vp), pathP, &nextVc, u.u_cred, 0);
+ code = afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred, 0);
else
code =
- afs_lookup(VTOAFS(vp), pathP, &nextVc, u.u_cred,
+ afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred,
AFS_LOOKUP_NOEVAL);
#else
- code = afs_lookup(VTOAFS(vp), pathP, &nextVc, u.u_cred, 0);
+ code = afs_lookup(VTOAFS(vp), pathP, &nextVc, get_user_struct()->u_cred, 0);
#endif /* AFS_WEB_ENHANCEMENTS */
if (nextVc)
nextVp=AFSTOV(nextVc);
/*
* Read the link data
*/
- code = afs_readlink(VTOAFS(vp), &uio, u.u_cred);
+ code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred);
if (code) {
afs_osi_Free(pathP, MAX_OSI_PATH + 1);
return code;
usr_vattr_null(&attrs);
attrs.va_type = VREG;
attrs.va_mode = mode;
- attrs.va_uid = u.u_cred->cr_uid;
- attrs.va_gid = u.u_cred->cr_gid;
+ attrs.va_uid = afs_cr_uid(get_user_struct()->u_cred);
+ attrs.va_gid = afs_cr_gid(get_user_struct()->u_cred);
dirP = NULL;
- code = afs_mkdir(VTOAFS(parentP), nameP, &attrs, &dirP, u.u_cred);
+ code = afs_mkdir(VTOAFS(parentP), nameP, &attrs, &dirP, get_user_struct()->u_cred);
VN_RELE(parentP);
if (code != 0) {
errno = code;
usr_vattr_null(&attrs);
attrs.va_type = VREG;
attrs.va_mode = mode;
- attrs.va_uid = u.u_cred->cr_uid;
- attrs.va_gid = u.u_cred->cr_gid;
+ attrs.va_uid = afs_cr_uid(get_user_struct()->u_cred);
+ attrs.va_gid = afs_cr_gid(get_user_struct()->u_cred);
if (flags & O_TRUNC) {
attrs.va_size = 0;
}
code =
afs_create(VTOAFS(dirP), nameP, &attrs,
(flags & O_EXCL) ? usr_EXCL : usr_NONEXCL, mode,
- &vc, u.u_cred);
+ &vc, get_user_struct()->u_cred);
VN_RELE(dirP);
if (code != 0) {
errno = code;
}
if (!fileMode)
fileMode = VREAD; /* since O_RDONLY is 0 */
- code = afs_access(VTOAFS(fileP), fileMode, u.u_cred);
+ code = afs_access(VTOAFS(fileP), fileMode, get_user_struct()->u_cred);
if (code != 0) {
VN_RELE(fileP);
errno = code;
/*
* Get the file attributes, all we need is the size
*/
- code = afs_getattr(VTOAFS(fileP), &attrs, u.u_cred);
+ code = afs_getattr(VTOAFS(fileP), &attrs, get_user_struct()->u_cred);
if (code != 0) {
VN_RELE(fileP);
errno = code;
usr_vattr_null(&attrs);
attrs.va_mask = ATTR_SIZE;
attrs.va_size = 0;
- code = afs_setattr(VTOAFS(fileP), &attrs, u.u_cred);
+ code = afs_setattr(VTOAFS(fileP), &attrs, get_user_struct()->u_cred);
if (code != 0) {
VN_RELE(fileP);
errno = code;
/*
* do the open
*/
- code = afs_open(&vc, openFlags, u.u_cred);
+ code = afs_open(&vc, openFlags, get_user_struct()->u_cred);
if (code != 0) {
VN_RELE(fileP);
errno = code;
* do the write
*/
- code = afs_write(VTOAFS(fileP), &uio, afs_FileFlags[fd], u.u_cred, 0);
+ code = afs_write(VTOAFS(fileP), &uio, afs_FileFlags[fd], get_user_struct()->u_cred, 0);
if (code) {
errno = code;
return -1;
/*
* do the read
*/
- code = afs_read(VTOAFS(fileP), &uio, u.u_cred, 0, &bufP, 0);
+ code = afs_read(VTOAFS(fileP), &uio, get_user_struct()->u_cred, 0, &bufP, 0);
if (code) {
errno = code;
return -1;
/*
* Get the attributes
*/
- code = afs_getattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_getattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
if (code != 0) {
return code;
}
usr_vattr_null(&attrs);
attrs.va_mask = ATTR_MODE;
attrs.va_mode = mode;
- code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_setattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
VN_RELE(vp);
if (code != 0) {
errno = code;
usr_vattr_null(&attrs);
attrs.va_mask = ATTR_MODE;
attrs.va_mode = mode;
- code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_setattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return -1;
usr_vattr_null(&attrs);
attrs.va_mask = ATTR_SIZE;
attrs.va_size = length;
- code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_setattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
VN_RELE(vp);
if (code != 0) {
errno = code;
usr_vattr_null(&attrs);
attrs.va_mask = ATTR_SIZE;
attrs.va_size = length;
- code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_setattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return -1;
newpos = offset;
break;
case SEEK_END:
- code = afs_getattr(VTOAFS(vp), &attrs, u.u_cred);
+ code = afs_getattr(VTOAFS(vp), &attrs, get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return -1;
return -1;
}
- code = afs_fsync(VTOAFS(fileP), u.u_cred);
+ code = afs_fsync(VTOAFS(fileP), get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return -1;
}
afs_FileTable[fd] = NULL;
- code = afs_close(VTOAFS(fileP), afs_FileFlags[fd], u.u_cred);
+ code = afs_close(VTOAFS(fileP), afs_FileFlags[fd], get_user_struct()->u_cred);
VN_RELE(fileP);
if (code != 0) {
errno = code;
/*
* Create the link
*/
- code = afs_link(VTOAFS(existP), VTOAFS(dirP), nameP, u.u_cred);
+ code = afs_link(VTOAFS(existP), VTOAFS(dirP), nameP, get_user_struct()->u_cred);
VN_RELE(existP);
VN_RELE(dirP);
if (code != 0) {
usr_vattr_null(&attrs);
attrs.va_type = VLNK;
attrs.va_mode = 0777;
- attrs.va_uid = u.u_cred->cr_uid;
- attrs.va_gid = u.u_cred->cr_gid;
- code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, u.u_cred);
+ attrs.va_uid = afs_cr_uid(get_user_struct()->u_cred);
+ attrs.va_gid = afs_cr_gid(get_user_struct()->u_cred);
+ code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, get_user_struct()->u_cred);
VN_RELE(dirP);
if (code != 0) {
errno = code;
/*
* Read the the link
*/
- code = afs_readlink(VTOAFS(vp), &uio, u.u_cred);
+ code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred);
VN_RELE(vp);
if (code) {
errno = code;
/*
* Remove the file
*/
- code = afs_remove(VTOAFS(dirP), nameP, u.u_cred);
+ code = afs_remove(VTOAFS(dirP), nameP, get_user_struct()->u_cred);
VN_RELE(dirP);
if (code != 0) {
errno = code;
/*
* Rename the file
*/
- code = afs_rename(VTOAFS(odirP), onameP, VTOAFS(ndirP), nnameP, u.u_cred);
+ code = afs_rename(VTOAFS(odirP), onameP, VTOAFS(ndirP), nnameP, get_user_struct()->u_cred);
VN_RELE(odirP);
VN_RELE(ndirP);
if (code != 0) {
/*
* Remove the directory
*/
- code = afs_rmdir(VTOAFS(dirP), nameP, u.u_cred);
+ code = afs_rmdir(VTOAFS(dirP), nameP, get_user_struct()->u_cred);
VN_RELE(dirP);
if (code != 0) {
errno = code;
/*
* read the next chunk from the directory
*/
- code = afs_readdir(VTOAFS(vp), &uio, u.u_cred);
+ code = afs_readdir(VTOAFS(vp), &uio, get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return -1;
struct usr_dirent *direntP;
struct min_direct *directP;
+ if (!dirp) {
+ errno = EBADF;
+ return NULL;
+ }
+
/*
* Make sure this is an open file
*/
/*
* read the next chunk from the directory
*/
- code = afs_readdir(VTOAFS(vp), &uio, u.u_cred);
+ code = afs_readdir(VTOAFS(vp), &uio, get_user_struct()->u_cred);
if (code != 0) {
errno = code;
return NULL;
int fd;
int rc;
+ if (!dirp) {
+ errno = EBADF;
+ return -1;
+ }
+
fd = dirp->dd_fd;
afs_osi_Free((char *)dirp,
sizeof(usr_DIR) + USR_DIRSIZE + sizeof(struct usr_dirent));
PRSFS_READ | PRSFS_WRITE | PRSFS_INSERT | PRSFS_LOOKUP | PRSFS_DELETE
| PRSFS_LOCK | PRSFS_ADMINISTER;
- afs_rights = afs_getRights(VTOAFS(vp), afs_rights, u.u_cred);
+ afs_rights = afs_getRights(VTOAFS(vp), afs_rights, get_user_struct()->u_cred);
AFS_GUNLOCK();
return afs_rights;