-
-int
-fill_pipeinfo(struct pipe * cpipe, struct pipe_info * pinfo)
-{
-#ifdef MAC
- int error;
-#endif
- struct timeval now;
- struct stat * ub;
-
- if (cpipe == NULL)
- return (EBADF);
-#ifdef MAC
- PIPE_LOCK(cpipe);
- error = mac_check_pipe_stat(active_cred, cpipe);
- PIPE_UNLOCK(cpipe);
- if (error)
- return (error);
-#endif
- if (cpipe->pipe_buffer.buffer == 0) {
- /*
- * must be stat'ing the write fd
- */
- cpipe = cpipe->pipe_peer;
-
- if (cpipe == NULL)
- return (EBADF);
- }
-
- ub = &pinfo->pipe_stat;
-
- bzero(ub, sizeof(*ub));
- ub->st_mode = S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
- ub->st_blksize = cpipe->pipe_buffer.size;
- ub->st_size = cpipe->pipe_buffer.cnt;
- if (ub->st_blksize != 0);
- ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize;
- ub->st_nlink = 1;
-
- ub->st_uid = kauth_getuid();
- ub->st_gid = kauth_getgid();
-
- microtime(&now);
- ub->st_atimespec.tv_sec = now.tv_sec;
- ub->st_atimespec.tv_nsec = now.tv_usec * 1000;
-
- ub->st_mtimespec.tv_sec = now.tv_sec;
- ub->st_mtimespec.tv_nsec = now.tv_usec * 1000;
-
- ub->st_ctimespec.tv_sec = now.tv_sec;
- ub->st_ctimespec.tv_nsec = now.tv_usec * 1000;
-
- /*
- * Left as 0: st_dev, st_ino, st_nlink, st_rdev, st_flags, st_gen, st_uid, st_gid.
- * XXX (st_dev, st_ino) should be unique.
- */
-
- pinfo->pipe_handle = (uint64_t)((uintptr_t)cpipe);
- pinfo->pipe_peerhandle = (uint64_t)((uintptr_t)(cpipe->pipe_peer));
- pinfo->pipe_status = cpipe->pipe_state;
- return (0);
-}
-