1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-11 14:10:34 +00:00

by changing the logic here we can support dynamic additions of new

filetypes.

Reviewed by: green
This commit is contained in:
Alfred Perlstein 2000-06-27 22:46:35 +00:00
parent ff56ceb1da
commit 974c7068d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62184
2 changed files with 24 additions and 38 deletions

View File

@ -256,6 +256,11 @@ fdesc_open(ap)
return (ENODEV);
}
/*
* !!!! READ THIS !!!!
* the proper way to handle this sort of thing is to do proper exclusion,
* so that adding new filetypes works properly at runtime
*/
static int
fdesc_getattr(ap)
struct vop_getattr_args /* {
@ -323,14 +328,13 @@ fdesc_getattr(ap)
vap->va_fileid = VTOFDESC(vp)->fd_ix;
vap->va_fsid = VNOVAL;
break;
case DTYPE_PIPE:
case DTYPE_SOCKET:
case DTYPE_KQUEUE:
default:
error = fo_stat(fp, &stb, ap->a_p);
if (error == 0) {
VATTR_NULL(vap);
if (fp->f_type == DTYPE_KQUEUE)
/* XXX Fake it! */
if (fp->f_type != DTYPE_PIPE && fp->f_type != DTYPE_SOCKET)
vap->va_type = VFIFO;
else
vap->va_type = IFTOVT(stb.st_mode);
@ -345,11 +349,9 @@ fdesc_getattr(ap)
vap->va_blocksize = stb.st_blksize;
/*
* XXX Sockets and kqueues don't have any
* mtime/atime/ctime data.
* XXX Only pipes have any mtime/atime/ctime data.
*/
if (fp->f_type == DTYPE_SOCKET ||
fp->f_type == DTYPE_KQUEUE) {
if (fp->f_type != DTYPE_PIPE) {
nanotime(&stb.st_atimespec);
stb.st_mtimespec = stb.st_atimespec;
stb.st_ctimespec = stb.st_mtimespec;
@ -361,9 +363,6 @@ fdesc_getattr(ap)
vap->va_gid = stb.st_gid;
}
break;
default:
panic("fdesc_getattr: Unknown fp->f_type encountered");
break;
}
break;
@ -412,18 +411,12 @@ fdesc_setattr(ap)
ap->a_cred, ap->a_p);
break;
case DTYPE_SOCKET:
case DTYPE_PIPE:
case DTYPE_KQUEUE:
default:
if (vap->va_flags != VNOVAL)
error = EOPNOTSUPP;
else
error = 0;
break;
default:
error = EBADF;
break;
}
return (error);

View File

@ -256,6 +256,11 @@ fdesc_open(ap)
return (ENODEV);
}
/*
* !!!! READ THIS !!!!
* the proper way to handle this sort of thing is to do proper exclusion,
* so that adding new filetypes works properly at runtime
*/
static int
fdesc_getattr(ap)
struct vop_getattr_args /* {
@ -323,14 +328,13 @@ fdesc_getattr(ap)
vap->va_fileid = VTOFDESC(vp)->fd_ix;
vap->va_fsid = VNOVAL;
break;
case DTYPE_PIPE:
case DTYPE_SOCKET:
case DTYPE_KQUEUE:
default:
error = fo_stat(fp, &stb, ap->a_p);
if (error == 0) {
VATTR_NULL(vap);
if (fp->f_type == DTYPE_KQUEUE)
/* XXX Fake it! */
if (fp->f_type != DTYPE_PIPE && fp->f_type != DTYPE_SOCKET)
vap->va_type = VFIFO;
else
vap->va_type = IFTOVT(stb.st_mode);
@ -345,11 +349,9 @@ fdesc_getattr(ap)
vap->va_blocksize = stb.st_blksize;
/*
* XXX Sockets and kqueues don't have any
* mtime/atime/ctime data.
* XXX Only pipes have any mtime/atime/ctime data.
*/
if (fp->f_type == DTYPE_SOCKET ||
fp->f_type == DTYPE_KQUEUE) {
if (fp->f_type != DTYPE_PIPE) {
nanotime(&stb.st_atimespec);
stb.st_mtimespec = stb.st_atimespec;
stb.st_ctimespec = stb.st_mtimespec;
@ -361,9 +363,6 @@ fdesc_getattr(ap)
vap->va_gid = stb.st_gid;
}
break;
default:
panic("fdesc_getattr: Unknown fp->f_type encountered");
break;
}
break;
@ -412,18 +411,12 @@ fdesc_setattr(ap)
ap->a_cred, ap->a_p);
break;
case DTYPE_SOCKET:
case DTYPE_PIPE:
case DTYPE_KQUEUE:
default:
if (vap->va_flags != VNOVAL)
error = EOPNOTSUPP;
else
error = 0;
break;
default:
error = EBADF;
break;
}
return (error);