Also, use S_IS* macros instead of manual comparison.
#include <minix/callnr.h>
#include <minix/u64.h>
#include <assert.h>
+#include <sys/stat.h>
#include "fs.h"
#include "file.h"
#include "fproc.h"
}
/* If the inode being closed is a pipe, release everyone hanging on it. */
- if (vp->v_pipe == I_PIPE) {
+ if (S_ISFIFO(vp->v_mode)) {
rw = (f->filp_mode & R_BIT ? WRITE : READ);
release(vp, rw, NR_PROCS);
}
/* If a write has been done, the inode is already marked as DIRTY. */
if (--f->filp_count == 0) {
- if (vp->v_pipe == I_PIPE) {
+ if (S_ISFIFO(vp->v_mode)) {
/* Last reader or writer is going. Tell PFS about latest
* pipe size.
*/
off_t newsize;
{
/* Truncate a regular file or a pipe */
- int r, file_type;
+ int r;
assert(tll_locked_by_me(&vp->v_lock));
- file_type = vp->v_mode & I_TYPE;
- if (file_type != I_REGULAR && file_type != I_NAMED_PIPE) return(EINVAL);
+ if (!S_ISREG(vp->v_mode) && !S_ISFIFO(vp->v_mode)) return(EINVAL);
/* We must not compare the old and the new size here: this function may be
* called for open(2), which requires an update to the file times if O_TRUNC
tll_upgrade(&vp->v_lock);
r = map_vnode(vp, PFS_PROC_NR);
if (r == OK) {
- vp->v_pipe = I_PIPE;
if (vp->v_ref_count == 1) {
vp->v_pipe_rd_pos = 0;
vp->v_pipe_wr_pos = 0;
* processes hanging on the pipe.
*/
- vp->v_pipe = I_PIPE;
-
if ((bits & (R_BIT|W_BIT)) == (R_BIT|W_BIT)) return(ENXIO);
/* Find the reader/writer at the other end of the pipe */
resolve.l_vnode_lock = VNODE_READ;
/* Only the super_user may make nodes other than fifos. */
- if (!super_user && (((mode_bits & I_TYPE) != I_NAMED_PIPE) &&
- ((mode_bits & I_TYPE) != I_UNIX_SOCKET))) {
+ if (!super_user && (!S_ISFIFO(mode_bits) && !S_ISSOCK(mode_bits))) {
return(EPERM);
}
bits = (mode_bits & I_TYPE) | (mode_bits & ALL_MODES & fp->fp_umask);
if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code);
/* Make sure that the object is a directory */
- if ((vp->v_mode & I_TYPE) != I_DIRECTORY) {
+ if (!S_ISDIR(vp->v_mode)) {
r = ENOTDIR;
} else if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) {
r = req_mknod(vp->v_fs_e, vp->v_inode_nr, fullpath, fp->fp_effuid,
if ((vp = last_dir(&resolve, fp)) == NULL) return(err_code);
/* Make sure that the object is a directory */
- if ((vp->v_mode & I_TYPE) != I_DIRECTORY) {
+ if (!S_ISDIR(vp->v_mode)) {
r = ENOTDIR;
} else if ((r = forbidden(fp, vp, W_BIT|X_BIT)) == OK) {
r = req_mkdir(vp->v_fs_e, vp->v_inode_nr, fullpath, fp->fp_effuid,
if ( (rfilp = get_filp(seekfd, VNODE_READ)) == NULL) return(err_code);
/* No lseek on pipes. */
- if (rfilp->filp_vno->v_pipe == I_PIPE) {
+ if (S_ISFIFO(rfilp->filp_vno->v_mode)) {
unlock_filp(rfilp);
return(ESPIPE);
}
if ( (rfilp = get_filp(seekfd, VNODE_READ)) == NULL) return(err_code);
/* No lseek on pipes. */
- if (rfilp->filp_vno->v_pipe == I_PIPE) {
+ if (S_ISFIFO(rfilp->filp_vno->v_mode)) {
unlock_filp(rfilp);
return(ESPIPE);
}
vp->v_inode_nr = res.inode_nr;
vp->v_mapinode_nr = res.inode_nr;
vp->v_mode = res.fmode;
- vp->v_pipe = I_PIPE;
vp->v_pipe_rd_pos= 0;
vp->v_pipe_wr_pos= 0;
vp->v_fs_count = 1;
if (size > SSIZE_MAX) return(EINVAL);
- if (vp->v_pipe == I_PIPE) {
+ if (S_ISFIFO(vp->v_mode)) {
if (fp->fp_cum_io_partial != 0) {
panic("VFS: read_write: fp_cum_io_partial not clear");
}
#include "fs.h"
#include <sys/time.h>
#include <sys/select.h>
+#include <sys/stat.h>
#include <minix/com.h>
#include <minix/u64.h>
#include <string.h>
static int is_pipe(struct filp *f)
{
/* Recognize either anonymous pipe or named pipe (FIFO) */
- return(f && f->filp_vno && (f->filp_vno->v_mode & I_TYPE) == I_NAMED_PIPE);
+ return(f && f->filp_vno && S_ISFIFO(f->filp_vno->v_mode));
}
/*===========================================================================*
if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
/* If we read from a pipe, send position too */
- if (rfilp->filp_vno->v_pipe == I_PIPE) {
+ if (S_ISFIFO(rfilp->filp_vno->v_mode)) {
if (rfilp->filp_mode & R_BIT)
if (ex64hi(rfilp->filp_pos) != 0) {
panic("do_fstat: bad position in pipe");
for (vp = &vnode[0]; vp < &vnode[NR_VNODES]; ++vp) {
if (vp->v_ref_count == 0 && !is_vnode_locked(vp)) {
- vp->v_pipe = NO_PIPE;
vp->v_uid = -1;
vp->v_gid = -1;
vp->v_sdev = NO_DEV;
#if 0
int v_ref_check; /* for consistency checks */
#endif
- char v_pipe; /* set to I_PIPE if pipe */
off_t v_pipe_rd_pos;
off_t v_pipe_wr_pos;
endpoint_t v_bfs_e; /* endpoint number for the FS proces in case
tll_t v_lock; /* three-level-lock */
} vnode[NR_VNODES];
-
-/* Field values. */
-#define NO_PIPE 0 /* i_pipe is NO_PIPE if inode is not a pipe */
-#define I_PIPE 1 /* i_pipe is I_PIPE if inode is a pipe */
-
/* vnode lock types mapping */
#define VNODE_READ TLL_READ
#define VNODE_OPCL TLL_READSER