diff --git a/include/minix/vfsif.h b/include/minix/vfsif.h index b4950c6bc..bffcf91c1 100644 --- a/include/minix/vfsif.h +++ b/include/minix/vfsif.h @@ -56,12 +56,13 @@ #define RES_PROTO m9_s3 /* RES_PROTO is defined as follows: - * |----------------| - * 7V 4CR 0 - * 15 0 + * |--------------------------------| + * 8O7 V 4 CR 0 + * 15 0 * mentioned bits are inclusive * CR: bits 4-0 encode no. concurrent requests are supported by FS * V: bits 7-5 encode version of protocol + * O: bit 8 encodes support for 64-bit file offsets */ #define RES_PROTO_CR_SHIFT 0 #define RES_PROTO_CR_MASK 0x1F @@ -74,6 +75,8 @@ #define VFS_FS_PROTO_PUT_VERSION(b,v) \ ((b) |= (((v) << RES_PROTO_V_SHIFT) & RES_PROTO_V_MASK)) #define VFS_FS_CURRENT_VERSION 1 /* Current version */ +#define RES_PROTO_BIGOFFT_SHIFT 8 +#define VFS_FS_PROTO_BIGOFFT(b) (b & RES_PROTO_BIGOFFT_SHIFT) /* VFS/FS flags */ #define REQ_RDONLY 001 diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 14ddd2fbc..3791b5a28 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -395,7 +395,7 @@ int dev_io( dev_t dev, /* major-minor device number */ int proc_e, /* in whose address space is buf? */ void *buf, /* virtual address of the buffer */ - u64_t pos, /* byte position */ + off_t pos, /* byte position */ size_t bytes, /* how many bytes to transfer */ int flags, /* special flags, like O_NONBLOCK */ int suspend_reopen /* Just suspend the process */ @@ -680,7 +680,7 @@ int do_ioctl() if (S_ISBLK(vp->v_mode)) r = bdev_ioctl(dev, who_e, ioctlrequest, argx); else - r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, cvu64(0), + r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, 0, ioctlrequest, f->filp_flags, suspend_reopen); } diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index 4f8d0ac11..f11500c22 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -487,9 +487,8 @@ char path[PATH_MAX]; /* path to script file */ */ enum { INSERT=FALSE, REPLACE=TRUE }; int n, r; - off_t pos; + off_t pos, new_pos; char *sp, *interp = NULL; - u64_t new_pos; unsigned int cum_io; char buf[_MAX_BLOCK_SIZE]; @@ -499,8 +498,8 @@ char path[PATH_MAX]; /* path to script file */ pos = 0; /* Read from the start of the file */ /* Issue request */ - r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(pos), READING, - VFS_PROC_NR, (vir_bytes) buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io); + r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, pos, READING, VFS_PROC_NR, + (vir_bytes) buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io); if (r != OK) return(r); n = vp->v_size; @@ -616,7 +615,7 @@ static int read_seg(struct exec_info *execi, off_t off, off_t seg_addr, size_t s * partially initialized. */ int r; - u64_t new_pos; + off_t new_pos; unsigned int cum_io; struct vnode *vp = ((struct vfs_exec_info *) execi->opaque)->vp; @@ -624,7 +623,7 @@ static int read_seg(struct exec_info *execi, off_t off, off_t seg_addr, size_t s if (off + seg_bytes > LONG_MAX) return(EIO); if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO); - if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(off), READING, + if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, off, READING, execi->proc_e, (vir_bytes) seg_addr, seg_bytes, &new_pos, &cum_io)) != OK) { printf("VFS: read_seg: req_readwrite failed (data)\n"); @@ -659,9 +658,8 @@ static void clo_exec(struct fproc *rfp) static int map_header(struct vfs_exec_info *execi) { int r; - u64_t new_pos; unsigned int cum_io; - off_t pos; + off_t pos, new_pos; static char hdr[PAGE_SIZE]; /* Assume that header is not larger than a page */ pos = 0; /* Read from the start of the file */ @@ -671,7 +669,7 @@ static int map_header(struct vfs_exec_info *execi) execi->args.hdr = hdr; r = req_readwrite(execi->vp->v_fs_e, execi->vp->v_inode_nr, - cvul64(pos), READING, VFS_PROC_NR, (vir_bytes) hdr, + pos, READING, VFS_PROC_NR, (vir_bytes) hdr, execi->args.hdr_len, &new_pos, &cum_io); if (r != OK) { printf("VFS: exec: map_header: req_readwrite failed\n"); diff --git a/servers/vfs/file.h b/servers/vfs/file.h index f28001249..fcb575c5a 100644 --- a/servers/vfs/file.h +++ b/servers/vfs/file.h @@ -11,7 +11,7 @@ EXTERN struct filp { int filp_state; /* state for crash recovery */ int filp_count; /* how many file descriptors share this slot?*/ struct vnode *filp_vno; /* vnode belonging to this file */ - u64_t filp_pos; /* file position */ + off_t filp_pos; /* file position */ mutex_t filp_lock; /* lock to gain exclusive access */ struct fproc *filp_softlock; /* if not NULL; this filp didn't lock the * vnode. Another filp already holds a lock diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index b3914757b..380f74c82 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -177,7 +177,7 @@ int get_fd(int start, mode_t bits, int *k, struct filp **fpt) assert(f->filp_count >= 0); if (f->filp_count == 0 && mutex_trylock(&f->filp_lock) == 0) { f->filp_mode = bits; - f->filp_pos = cvu64(0); + f->filp_pos = 0; f->filp_selectors = 0; f->filp_select_ops = 0; f->filp_pipe_select_ops = 0; diff --git a/servers/vfs/lock.c b/servers/vfs/lock.c index d113faa93..8d9e9ae6b 100644 --- a/servers/vfs/lock.c +++ b/servers/vfs/lock.c @@ -66,11 +66,7 @@ int req; /* either F_SETLK or F_SETLKW */ /* Compute the first and last bytes in the lock region. */ switch (flock.l_whence) { case SEEK_SET: first = 0; break; - case SEEK_CUR: - if (ex64hi(f->filp_pos) != 0) - panic("lock_op: position in file too high"); - first = ex64lo(f->filp_pos); - break; + case SEEK_CUR: first = f->filp_pos; break; case SEEK_END: first = f->filp_vno->v_size; break; default: return(EINVAL); } diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index e3bb2719b..4340db2f1 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -212,11 +212,7 @@ int do_fcntl() /* Figure out starting position base. */ switch(flock_arg.l_whence) { case SEEK_SET: start = 0; break; - case SEEK_CUR: - if (ex64hi(f->filp_pos) != 0) - panic("do_fcntl: position in file too high"); - start = ex64lo(f->filp_pos); - break; + case SEEK_CUR: start = f->filp_pos; break; case SEEK_END: start = f->filp_vno->v_size; break; default: r = EINVAL; } diff --git a/servers/vfs/open.c b/servers/vfs/open.c index ddbebe3f5..eeac7ecb5 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -596,7 +596,7 @@ int do_lseek_321() register struct filp *rfilp; int r = OK, seekfd, seekwhence; i32_t offset; - u64_t pos, newpos; + off_t pos, newpos; seekfd = job_m_in.ls_fd; seekwhence = job_m_in.whence; @@ -613,27 +613,24 @@ int do_lseek_321() /* The value of 'whence' determines the start position to use. */ switch(seekwhence) { - case SEEK_SET: pos = cvu64(0); break; - case SEEK_CUR: pos = rfilp->filp_pos; break; - case SEEK_END: pos = cvul64(rfilp->filp_vno->v_size); break; + case SEEK_SET: pos = 0; break; + case SEEK_CUR: pos = rfilp->filp_pos; break; + case SEEK_END: pos = rfilp->filp_vno->v_size; break; default: unlock_filp(rfilp); return(EINVAL); } - if (offset >= 0) - newpos = add64ul(pos, offset); - else - newpos = sub64ul(pos, -offset); + newpos = pos + offset; /* Check for overflow. */ - if (ex64hi(newpos) != 0) { + if (newpos > INT_MAX) { /* This is for backwards compatibility */ r = EOVERFLOW; - } else if ((i32_t) ex64lo(newpos) < 0) { /* no negative file size */ + } else if (newpos < 0) { /* no negative file size */ r = EOVERFLOW; } else { /* insert the new position into the output message */ - m_out.reply_l1 = ex64lo(newpos); + m_out.reply_l1 = (long) newpos; - if (cmp64(newpos, rfilp->filp_pos) != 0) { + if (newpos != rfilp->filp_pos) { rfilp->filp_pos = newpos; /* Inhibit read ahead request */ @@ -655,7 +652,7 @@ int do_lseek() register struct filp *rfilp; int r = OK, seekfd, seekwhence; off_t offset; - u64_t pos, newpos; + off_t pos, newpos; seekfd = job_m_in.ls_fd; seekwhence = job_m_in.whence; @@ -672,22 +669,23 @@ int do_lseek() /* The value of 'whence' determines the start position to use. */ switch(seekwhence) { - case SEEK_SET: pos = cvu64(0); break; - case SEEK_CUR: pos = rfilp->filp_pos; break; - case SEEK_END: pos = cvul64(rfilp->filp_vno->v_size); break; + case SEEK_SET: pos = 0; break; + case SEEK_CUR: pos = rfilp->filp_pos; break; + case SEEK_END: pos = rfilp->filp_vno->v_size; break; default: unlock_filp(rfilp); return(EINVAL); } - if (offset < 0 && -offset > pos) { /* no negative file size */ + newpos = pos + offset; + + if (newpos < 0) { /* no negative file size */ r = EOVERFLOW; } else { - newpos = pos + offset; /* insert the new position into the output message */ m_out.reply_l1 = ex64lo(newpos); m_out.reply_l2 = ex64hi(newpos); - if (cmp64(newpos, rfilp->filp_pos) != 0) { + if (newpos != rfilp->filp_pos) { rfilp->filp_pos = newpos; /* Inhibit read ahead request */ @@ -700,63 +698,6 @@ int do_lseek() return(r); } -/*===========================================================================* - * do_llseek * - *===========================================================================*/ -int do_llseek() -{ -/* Perform the llseek(ls_fd, offset, whence) system call. */ - register struct filp *rfilp; - u64_t pos, newpos; - int r = OK, seekfd, seekwhence; - long off_hi, off_lo; - - seekfd = job_m_in.ls_fd; - seekwhence = job_m_in.whence; - off_hi = job_m_in.offset_high; - off_lo = job_m_in.offset_lo; - - /* Check to see if the file descriptor is valid. */ - if ( (rfilp = get_filp(seekfd, VNODE_READ)) == NULL) return(err_code); - - /* No lseek on pipes. */ - if (S_ISFIFO(rfilp->filp_vno->v_mode)) { - unlock_filp(rfilp); - return(ESPIPE); - } - - /* The value of 'whence' determines the start position to use. */ - switch(seekwhence) { - case SEEK_SET: pos = cvu64(0); break; - case SEEK_CUR: pos = rfilp->filp_pos; break; - case SEEK_END: pos = cvul64(rfilp->filp_vno->v_size); break; - default: unlock_filp(rfilp); return(EINVAL); - } - - newpos = add64(pos, make64(off_lo, off_hi)); - - /* Check for overflow. */ - if ((off_hi > 0) && cmp64(newpos, pos) < 0) - r = EINVAL; - else if ((off_hi < 0) && cmp64(newpos, pos) > 0) - r = EINVAL; - else { - /* insert the new position into the output message */ - m_out.reply_l1 = ex64lo(newpos); - m_out.reply_l2 = ex64hi(newpos); - - if (cmp64(newpos, rfilp->filp_pos) != 0) { - rfilp->filp_pos = newpos; - - /* Inhibit read ahead request */ - r = req_inhibread(rfilp->filp_vno->v_fs_e, - rfilp->filp_vno->v_inode_nr); - } - } - - unlock_filp(rfilp); - return(r); -} /*===========================================================================* * do_close * diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 26eb9c041..4212aa50d 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -615,12 +615,12 @@ char ename[NAME_MAX + 1]; { #define DIR_ENTRIES 8 #define DIR_ENTRY_SIZE (sizeof(struct dirent) + NAME_MAX) - u64_t pos, new_pos; + off_t pos, new_pos; int r, consumed, totalbytes, name_len; char buf[DIR_ENTRY_SIZE * DIR_ENTRIES]; struct dirent *cur; - pos = make64(0, 0); + pos = 0; if (!S_ISDIR(dirp->v_mode)) return(EBADF); diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 9f750cfbf..61f08a8f9 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -34,7 +34,7 @@ void dev_reply(struct dmap *dp); int dev_close(dev_t dev, int filp_no); int bdev_open(dev_t dev, int access); int bdev_close(dev_t dev); -int dev_io(int op, dev_t dev, endpoint_t proc_e, void *buf, u64_t pos, +int dev_io(int op, dev_t dev, endpoint_t proc_e, void *buf, off_t pos, size_t bytes, int flags, int suspend_reopen); int gen_opcl(int op, dev_t dev, endpoint_t task_nr, int flags); int gen_io(endpoint_t driver_e, message *mess_ptr); @@ -218,9 +218,9 @@ int rw_pipe(int rw_flag, endpoint_t usr, struct filp *f, char *buf, size_t req_size); /* request.c */ -int req_breadwrite(endpoint_t fs_e, endpoint_t user_e, dev_t dev, u64_t pos, +int req_breadwrite(endpoint_t fs_e, endpoint_t user_e, dev_t dev, off_t pos, unsigned int num_of_bytes, vir_bytes user_addr, int rw_flag, - u64_t *new_posp, unsigned int *cum_iop); + off_t *new_posp, unsigned int *cum_iop); int req_chmod(endpoint_t fs_e, ino_t inode_nr, mode_t rmode, mode_t *new_modep); int req_chown(endpoint_t fs_e, ino_t inode_nr, uid_t newuid, gid_t newgid, @@ -231,8 +231,8 @@ int req_flush(endpoint_t fs_e, dev_t dev); int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf); int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf); int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end); -int req_getdents(endpoint_t fs_e, ino_t inode_nr, u64_t pos, char *buf, - size_t size, u64_t *new_pos, int direct, int getdents_321); +int req_getdents(endpoint_t fs_e, ino_t inode_nr, off_t pos, char *buf, + size_t size, off_t *new_pos, int direct, int getdents_321); int req_inhibread(endpoint_t fs_e, ino_t inode_nr); int req_link(endpoint_t fs_e, ino_t link_parent, char *lastc, ino_t linked_file); @@ -251,9 +251,9 @@ int req_rdlink(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf, size_t len, int direct); int req_readsuper(struct vmnt *vmp, char *driver_name, dev_t dev, int readonly, int isroot, struct node_details *res_nodep); -int req_readwrite(endpoint_t fs_e, ino_t inode_nr, u64_t pos, int rw_flag, +int req_readwrite(endpoint_t fs_e, ino_t inode_nr, off_t pos, int rw_flag, endpoint_t user_e, vir_bytes user_addr, unsigned int num_of_bytes, - u64_t *new_posp, unsigned int *cum_iop); + off_t *new_posp, unsigned int *cum_iop); int req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir, char *new_name); int req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index b97ec50f3..6d657f16e 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -126,7 +126,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, endpoint_t for_e) { register struct vnode *vp; - u64_t position, res_pos, new_pos; + off_t position, res_pos, new_pos; unsigned int cum_io, cum_io_incr, res_cum_io; int op, r; @@ -164,7 +164,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, suspend_reopen); if (r >= 0) { cum_io = r; - position = add64ul(position, r); + position += cum_io; r = OK; } } else if (S_ISBLK(vp->v_mode)) { /* Block special files. */ @@ -186,7 +186,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, } else { /* Regular files */ if (rw_flag == WRITING) { /* Check for O_APPEND flag. */ - if (f->filp_flags & O_APPEND) position = cvul64(vp->v_size); + if (f->filp_flags & O_APPEND) position = vp->v_size; } /* Issue request */ @@ -194,9 +194,6 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, (vir_bytes) buf, size, &new_pos, &cum_io_incr); if (r >= 0) { - if (ex64hi(new_pos)) - panic("read_write: bad new pos"); - position = new_pos; cum_io += cum_io_incr; } @@ -205,11 +202,8 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size, /* On write, update file size and access time. */ if (rw_flag == WRITING) { if (S_ISREG(vp->v_mode) || S_ISDIR(vp->v_mode)) { - if (cmp64ul(position, vp->v_size) > 0) { - if (ex64hi(position) != 0) { - panic("read_write: file size too big "); - } - vp->v_size = ex64lo(position); + if (position > vp->v_size) { + vp->v_size = position; } } } @@ -238,7 +232,7 @@ int do_getdents() { /* Perform the getdents(fd, buf, size) system call. */ int r = OK, getdents_321 = 0; - u64_t new_pos; + off_t new_pos; register struct filp *rfilp; if (job_call_nr == GETDENTS_321) getdents_321 = 1; @@ -256,9 +250,6 @@ int do_getdents() r = EBADF; if (r == OK) { - if (ex64hi(rfilp->filp_pos) != 0) - panic("do_getdents: can't handle large offsets"); - r = req_getdents(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr, rfilp->filp_pos, scratch(fp).io.io_buffer, scratch(fp).io.io_nbytes, &new_pos, 0, getdents_321); @@ -284,7 +275,7 @@ size_t req_size; int r, oflags, partial_pipe = 0; size_t size, cum_io, cum_io_incr; struct vnode *vp; - u64_t position, new_pos; + off_t position, new_pos; /* Must make sure we're operating on locked filp and vnode */ assert(tll_locked_by_me(&f->filp_vno->v_lock)); @@ -292,7 +283,7 @@ size_t req_size; oflags = f->filp_flags; vp = f->filp_vno; - position = cvu64(0); /* Not actually used */ + position = 0; /* Not actually used */ /* fp->fp_cum_io_partial is only nonzero when doing partial writes */ cum_io = fp->fp_cum_io_partial; @@ -321,14 +312,11 @@ size_t req_size; return(r); } - if (ex64hi(new_pos)) - panic("rw_pipe: bad new pos"); - cum_io += cum_io_incr; buf += cum_io_incr; req_size -= cum_io_incr; - vp->v_size = ex64lo(new_pos); + vp->v_size = new_pos; if (partial_pipe) { /* partial write on pipe with */ diff --git a/servers/vfs/request.c b/servers/vfs/request.c index e8bda6f1f..12f508335 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -35,11 +35,11 @@ int req_breadwrite( endpoint_t fs_e, endpoint_t user_e, dev_t dev, - u64_t pos, + off_t pos, unsigned int num_of_bytes, vir_bytes user_addr, int rw_flag, - u64_t *new_posp, + off_t *new_pos, unsigned int *cum_iop ) { @@ -66,7 +66,7 @@ int req_breadwrite( if (r != OK) return(r); /* Fill in response structure */ - *new_posp = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); + *new_pos = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); *cum_iop = m.RES_NBYTES; return(OK); @@ -148,9 +148,9 @@ int req_create( cp_grant_id_t grant_id; size_t len; message m; + struct vmnt *vmp; - if (path[0] == '/') - panic("req_create: filename starts with '/'"); + vmp = find_vmnt(fs_e); len = strlen(path) + 1; grant_id = cpf_grant_direct(fs_e, (vir_bytes) path, len, CPF_READ); @@ -175,7 +175,11 @@ int req_create( res->fs_e = m.m_source; res->inode_nr = (ino_t) m.RES_INODE_NR; res->fmode = (mode_t) m.RES_MODE; - res->fsize = m.RES_FILE_SIZE_LO; + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + res->fsize = make64(m.RES_FILE_SIZE_LO, m.RES_FILE_SIZE_HI); + } else { + res->fsize = m.RES_FILE_SIZE_LO; + } res->uid = (uid_t) m.RES_UID; res->gid = (gid_t) m.RES_GID; res->dev = NO_DEV; @@ -258,14 +262,33 @@ int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf) int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end) { message m; + struct vmnt *vmp; + + vmp = find_vmnt(fs_e); /* Fill in request message */ m.m_type = REQ_FTRUNC; m.REQ_INODE_NR = (pino_t) inode_nr; - m.REQ_TRC_START_LO = start; - m.REQ_TRC_START_HI = 0; /* Not used for now, so clear it. */ - m.REQ_TRC_END_LO = end; - m.REQ_TRC_END_HI = 0; /* Not used for now, so clear it. */ + + m.REQ_TRC_START_LO = ex64lo(start); + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + m.REQ_TRC_START_HI = ex64hi(start); + } else if (start > INT_MAX) { + /* FS does not support 64-bit off_t and 32 bits is not enough */ + return EINVAL; + } else { + m.REQ_TRC_START_HI = 0; + } + + m.REQ_TRC_END_LO = ex64lo(end); + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + m.REQ_TRC_END_HI = ex64hi(end); + } else if (end > INT_MAX) { + /* FS does not support 64-bit off_t and 32 bits is not enough */ + return EINVAL; + } else { + m.REQ_TRC_END_HI = 0; + } /* Send/rec request */ return fs_sendrec(fs_e, &m); @@ -278,10 +301,10 @@ int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end) int req_getdents( endpoint_t fs_e, ino_t inode_nr, - u64_t pos, + off_t pos, char *buf, size_t size, - u64_t *new_pos, + off_t *new_pos, int direct, int getdents_321 /* Set to 1 if user land expects old format */ ) @@ -352,7 +375,16 @@ int req_getdents( m.REQ_GRANT = grant_id; m.REQ_MEM_SIZE = size; m.REQ_SEEK_POS_LO = ex64lo(pos); - m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + m.REQ_SEEK_POS_HI = ex64hi(pos); + } else if (pos > INT_MAX) { + /* FS does not support 64-bit off_t and 32 bits is not enough */ + if (indir_buf_src != NULL) free(indir_buf_src); + if (indir_buf_dst != NULL) free(indir_buf_dst); + return EINVAL; + } else { + m.REQ_SEEK_POS_HI = 0; + } r = fs_sendrec(fs_e, &m); cpf_revoke(grant_id); @@ -373,7 +405,11 @@ int req_getdents( } if (r == OK) { - *new_pos = cvul64(m.RES_SEEK_POS_LO); + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + *new_pos = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); + } else { + *new_pos = m.RES_SEEK_POS_LO; + } r = m.RES_NBYTES; } @@ -499,12 +535,14 @@ int req_lookup( struct fproc *rfp ) { - int r; - size_t len; - cp_grant_id_t grant_id=0, grant_id2=0; message m; vfs_ucred_t credentials; - int flags; + int r, flags; + size_t len; + struct vmnt *vmp; + cp_grant_id_t grant_id=0, grant_id2=0; + + vmp = find_vmnt(fs_e); grant_id = cpf_grant_direct(fs_e, (vir_bytes) resolve->l_path, PATH_MAX, CPF_READ | CPF_WRITE); @@ -561,7 +599,11 @@ int req_lookup( case OK: res->inode_nr = (ino_t) m.RES_INODE_NR; res->fmode = (mode_t) m.RES_MODE; - res->fsize = m.RES_FILE_SIZE_LO; + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + res->fsize = make64(m.RES_FILE_SIZE_LO, m.RES_FILE_SIZE_HI); + } else { + res->fsize = m.RES_FILE_SIZE_LO; + } res->dev = m.RES_DEV; res->uid = (uid_t) m.RES_UID; res->gid = (gid_t) m.RES_GID; @@ -695,9 +737,12 @@ int req_newnode( struct node_details *res ) { + struct vmnt *vmp; int r; message m; + vmp = find_vmnt(fs_e); + /* Fill in request message */ m.m_type = REQ_NEWNODE; m.REQ_MODE = (pmode_t) dmode; @@ -711,7 +756,11 @@ int req_newnode( res->fs_e = m.m_source; res->inode_nr = (ino_t) m.RES_INODE_NR; res->fmode = (mode_t) m.RES_MODE; - res->fsize = m.RES_FILE_SIZE_LO; + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + res->fsize = make64(m.RES_FILE_SIZE_LO, m.RES_FILE_SIZE_HI); + } else { + res->fsize = m.RES_FILE_SIZE_LO; + } res->dev = m.RES_DEV; res->uid = (uid_t) m.RES_UID; res->gid = (gid_t) m.RES_GID; @@ -823,7 +872,7 @@ int req_readsuper( dev_t dev, int readonly, int isroot, - struct node_details *res_nodep + struct node_details *res ) { int r; @@ -857,13 +906,17 @@ int req_readsuper( if(r == OK) { /* Fill in response structure */ - res_nodep->fs_e = m.m_source; - res_nodep->inode_nr = (ino_t) m.RES_INODE_NR; + res->fs_e = m.m_source; + res->inode_nr = (ino_t) m.RES_INODE_NR; vmp->m_proto = m.RES_PROTO; - res_nodep->fmode = (mode_t) m.RES_MODE; - res_nodep->fsize = m.RES_FILE_SIZE_LO; - res_nodep->uid = (uid_t) m.RES_UID; - res_nodep->gid = (gid_t) m.RES_GID; + res->fmode = (mode_t) m.RES_MODE; + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + res->fsize = make64(m.RES_FILE_SIZE_LO, m.RES_FILE_SIZE_HI); + } else { + res->fsize = m.RES_FILE_SIZE_LO; + } + res->uid = (uid_t) m.RES_UID; + res->gid = (gid_t) m.RES_GID; } return(r); @@ -873,18 +926,18 @@ int req_readsuper( /*===========================================================================* * req_readwrite * *===========================================================================*/ -int req_readwrite(fs_e, inode_nr, pos, rw_flag, user_e, - user_addr, num_of_bytes, new_posp, cum_iop) -endpoint_t fs_e; -ino_t inode_nr; -u64_t pos; -int rw_flag; -endpoint_t user_e; -vir_bytes user_addr; -unsigned int num_of_bytes; -u64_t *new_posp; -unsigned int *cum_iop; +int req_readwrite( +endpoint_t fs_e, +ino_t inode_nr, +off_t pos, +int rw_flag, +endpoint_t user_e, +vir_bytes user_addr, +unsigned int num_of_bytes, +off_t *new_posp, +unsigned int *cum_iop) { + struct vmnt *vmp; int r; cp_grant_id_t grant_id = -1; message m; @@ -897,9 +950,7 @@ unsigned int *cum_iop; * PEEKING: do i/o in FS, just get the blocks into the cache, no copy */ - if (ex64hi(pos) != 0) - panic("req_readwrite: pos too large"); - + vmp = find_vmnt(fs_e); assert(rw_flag == READING || rw_flag == WRITING || rw_flag == PEEKING); switch(rw_flag) { @@ -926,7 +977,13 @@ unsigned int *cum_iop; m.REQ_INODE_NR = (pino_t) inode_nr; m.REQ_GRANT = grant_id; m.REQ_SEEK_POS_LO = ex64lo(pos); - m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + m.REQ_SEEK_POS_HI = ex64hi(pos); + } else if (pos > INT_MAX) { + return EINVAL; + } else { + m.REQ_SEEK_POS_HI = 0; + } m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ @@ -935,7 +992,11 @@ unsigned int *cum_iop; if (r == OK) { /* Fill in response structure */ - *new_posp = cvul64(m.RES_SEEK_POS_LO); + if (VFS_FS_PROTO_BIGOFFT(vmp->m_proto)) { + *new_posp = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); + } else { + *new_posp = m.RES_SEEK_POS_LO; + } *cum_iop = m.RES_NBYTES; } diff --git a/servers/vfs/select.c b/servers/vfs/select.c index bc46430b3..ab1ce92aa 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -382,8 +382,7 @@ static int select_request_async(struct filp *f, int *ops, int block) return(SUSPEND); f->filp_select_flags &= ~FSF_UPDATE; - r = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, - cvu64(0), 0, 0, FALSE); + r = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, 0, 0, 0, FALSE); if (r < 0 && r != SUSPEND) return(r); @@ -434,8 +433,7 @@ static int select_request_sync(struct filp *f, int *ops, int block) rops = *ops; if (block) rops |= SEL_NOTIFY; - *ops = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, - cvu64(0), 0, 0, FALSE); + *ops = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, 0, 0, 0,FALSE); if (*ops < 0) return(*ops); diff --git a/servers/vfs/table.c b/servers/vfs/table.c index 81b20c6f6..f16fe4912 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -96,7 +96,7 @@ int (*call_vec[])(void) = { no_sys, /* 78 = (sysuname) */ no_sys, /* 79 = unused */ do_getdents, /* 80 = getdents_321 (to be phased out) */ - do_llseek, /* 81 = llseek */ + do_lseek, /* 81 = llseek */ do_fstatfs, /* 82 = fstatfs */ do_statvfs, /* 83 = fstatvfs */ do_fstatvfs, /* 84 = statvfs */ diff --git a/servers/vfs/vnode.h b/servers/vfs/vnode.h index 2f01d7379..e9f7cdc5e 100644 --- a/servers/vfs/vnode.h +++ b/servers/vfs/vnode.h @@ -13,9 +13,6 @@ EXTERN struct vnode { int v_ref_count; /* # times vnode used; 0 means slot is free */ int v_fs_count; /* # reference at the underlying FS */ int v_mapfs_count; /* # reference at the underlying mapped FS */ -#if 0 - int v_ref_check; /* for consistency checks */ -#endif endpoint_t v_bfs_e; /* endpoint number for the FS proces in case of a block special file */ dev_t v_dev; /* device number on which the corresponding