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:
parent
b160a51e51
commit
2db4b023bb
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user