afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
afs_int32 asize)
{
- size_t resid;
- register afs_int32 code;
+ struct uio auio;
+ struct iovec iov;
+ afs_int32 code;
+
AFS_STATCNT(osi_Read);
- /**
- * If the osi_file passed in is NULL, panic only if AFS is not shutting
- * down. No point in crashing when we are already shutting down
- */
+ /*
+ * If the osi_file passed in is NULL, panic only if AFS is not shutting
+ * down. No point in crashing when we are already shutting down
+ */
if (!afile) {
if (!afs_shuttingdown)
osi_Panic("osi_Read called with null param");
if (offset != -1)
afile->offset = offset;
+ setup_uio(&auio, &iov, aptr, afile->offset, asize, UIO_READ, AFS_UIOSYS);
AFS_GUNLOCK();
- code = osi_rdwr(UIO_READ, afile, (caddr_t) aptr, asize, &resid);
+ code = osi_rdwr(afile, &auio, UIO_READ);
AFS_GLOCK();
if (code == 0) {
- code = asize - resid;
+ code = asize - auio.uio_resid;
afile->offset += code;
} else {
- afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
+ afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, auio.uio_resid,
ICL_TYPE_INT32, code);
code = -1;
}
afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
afs_int32 asize)
{
- size_t resid;
- register afs_int32 code;
+ struct uio auio;
+ struct iovec iov;
+ afs_int32 code;
+
AFS_STATCNT(osi_Write);
+
if (!afile) {
if (!afs_shuttingdown)
osi_Panic("afs_osi_Write called with null param");
else
return EIO;
}
+
if (offset != -1)
afile->offset = offset;
+ setup_uio(&auio, &iov, aptr, afile->offset, asize, UIO_WRITE, AFS_UIOSYS);
AFS_GUNLOCK();
- code = osi_rdwr(UIO_WRITE, afile, (caddr_t) aptr, asize, &resid);
+ code = osi_rdwr(afile, &auio, UIO_WRITE);
AFS_GLOCK();
if (code == 0) {
- code = asize - resid;
+ code = asize - auio.uio_resid;
afile->offset += code;
} else {
if (code == ENOSPC)
("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
code = -1;
}
- if (afile->proc) {
- (*afile->proc) (afile, code);
- }
+
+ if (afile->proc)
+ (*afile->proc)(afile, code);
+
return code;
}
#define FOP_WRITE(F, B, C) (F)->f_op->write(F, B, (size_t)(C), &(F)->f_pos)
/* osi_rdwr
- * Seek, then read or write to an open inode. addrp points to data in
+ * seek, then read or write to an open inode. addrp points to data in
* kernel space.
*/
int
-osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize,
- size_t * resid)
-{
- int code = 0;
- KERNEL_SPACE_DECL;
- struct file *filp = &file->file;
- off_t offset = file->offset;
- unsigned long savelim;
-
- /* Seek to the desired position. Return -1 on error. */
- if (filp->f_op->llseek) {
- if (filp->f_op->llseek(filp, (loff_t) offset, 0) != offset)
- return -1;
- } else
- filp->f_pos = offset;
-
- savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
- current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
-
- /* Read/Write the data. */
- TO_USER_SPACE();
- if (rw == UIO_READ)
- code = FOP_READ(filp, addrp, asize);
- else if (rw == UIO_WRITE)
- code = FOP_WRITE(filp, addrp, asize);
- else /* all is well? */
- code = asize;
- TO_KERNEL_SPACE();
-
- current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim;
-
- if (code >= 0) {
- *resid = asize - code;
- return 0;
- } else
- return -1;
-}
-
-/* This variant is called from AFS read/write routines and takes a uio
- * struct and, if successful, returns 0.
- */
-int
-osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
+osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
{
struct file *filp = &osifile->file;
KERNEL_SPACE_DECL;
int code = 0;
struct iovec *iov;
- int count;
+ afs_size_t count;
unsigned long savelim;
savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
if (uiop->uio_seg == AFS_UIOSYS)
TO_USER_SPACE();
- filp->f_pos = uiop->uio_offset;
+ /* seek to the desired position. Return -1 on error. */
+ if (filp->f_op->llseek) {
+ if (filp->f_op->llseek(filp, (loff_t) uiop->uio_offset, 0) != uiop->uio_offset)
+ return -1;
+ } else
+ filp->f_pos = uiop->uio_offset;
+
while (code == 0 && uiop->uio_resid > 0 && uiop->uio_iovcnt > 0) {
iov = uiop->uio_iov;
count = iov->iov_len;
extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink,
struct dentry **dpp);
extern int osi_InitCacheInfo(char *aname);
-extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp,
- size_t asize, size_t * resid);
-extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
+extern int osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
extern void afs_osi_SetTime(osi_timeval_t * tvp);
extern void osi_linux_free_inode_pages(void);
extern void check_bad_parent(struct dentry *dp);
AFS_GLOCK();
#elif defined(AFS_LINUX20_ENV)
AFS_GUNLOCK();
- code = osi_file_uio_rdwr(tfile, &tuio, UIO_READ);
+ code = osi_rdwr(tfile, &tuio, UIO_READ);
AFS_GLOCK();
#elif defined(AFS_DARWIN_ENV)
AFS_GUNLOCK();
}
#elif defined(AFS_LINUX20_ENV)
AFS_GUNLOCK();
- code = osi_file_uio_rdwr(tfile, &tuio, UIO_WRITE);
+ code = osi_rdwr(tfile, &tuio, UIO_WRITE);
AFS_GLOCK();
#elif defined(AFS_DARWIN_ENV)
AFS_GUNLOCK();
extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink,
struct dentry **dpp);
extern int osi_InitCacheInfo(char *aname);
-extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp,
- size_t asize, size_t * resid);
-extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
+extern int osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
extern void setup_uio(uio_t * uiop, struct iovec *iovecp, const char *buf,
afs_offs_t pos, int count, uio_flag_t flag,
uio_seg_t seg);