Introduce a new flag on a file descriptor: DFLAG_SEEKABLE and use that

rather than assume that only DTYPE_VNODE is seekable.
This commit is contained in:
Poul-Henning Kamp 2003-06-18 19:53:59 +00:00
parent b160a51e51
commit 2db4b023bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116550
5 changed files with 8 additions and 7 deletions

View File

@ -137,7 +137,7 @@ pread(td, uap)
if ((error = fget_read(td, uap->fd, &fp)) != 0)
return (error);
if (fp->f_type != DTYPE_VNODE) {
if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE)) {
error = ESPIPE;
} else {
error = dofileread(td, fp, uap->fd, uap->buf, uap->nbyte,
@ -360,11 +360,11 @@ pwrite(td, uap)
int error;
if ((error = fget_write(td, uap->fd, &fp)) == 0) {
if (fp->f_type == DTYPE_VNODE) {
if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE)) {
error = ESPIPE;
} else {
error = dofilewrite(td, fp, uap->fd, uap->buf,
uap->nbyte, uap->offset, FOF_OFFSET);
} else {
error = ESPIPE;
}
fdrop(fp, td);
} else {

View File

@ -1341,7 +1341,7 @@ lseek(td, uap)
if ((error = fget(td, uap->fd, &fp)) != 0)
return (error);
if (fp->f_type != DTYPE_VNODE) {
if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE)) {
fdrop(fp, td);
return (ESPIPE);
}

View File

@ -1341,7 +1341,7 @@ lseek(td, uap)
if ((error = fget(td, uap->fd, &fp)) != 0)
return (error);
if (fp->f_type != DTYPE_VNODE) {
if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE)) {
fdrop(fp, td);
return (ESPIPE);
}

View File

@ -80,7 +80,7 @@ struct fileops vnops = {
.fo_kqfilter = vn_kqfilter,
.fo_stat = vn_statfile,
.fo_close = vn_closefile,
.fo_flags = DFLAG_PASSABLE
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
};
int

View File

@ -94,6 +94,7 @@ struct fileops {
};
#define DFLAG_PASSABLE 0x01 /* may be passed via unix sockets. */
#define DFLAG_SEEKABLE 0x02 /* seekable / nonsequential */
/*
* Kernel descriptor table.