📄 head.h
字号:
/* -*- Mode: C -*- * head.h --- streams head handling * Author : Graham Wheeler, Francisco J. Ballesteros * Created On : Tue May 31 22:25:19 1994 * Last Modified By: David Grothe * RCS Id : head.h,v 1.1.1.3 2003/12/27 21:12:52 brian Exp * Purpose : here you have utilites to handle str heads. * ----------------______________________________________________ * * Copyright (C) 1995 Graham Wheeler, Francisco J. Ballesteros, * Denis Froschauer * Copyright (C) 1997 David Grothe, Gcom, Inc <dave@gcom.com> * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, * MA 02139, USA. * * * You can reach us by email to any of * gram@aztec.co.za, nemo@ordago.uc3m.es, 100741.1151@compuserve.com * dave@gcom.com */#ifndef _HEAD_H#define _HEAD_H 1#ident "@(#) LiS head.h 2.26 12/27/03 15:12:51 "/* ------------------------------------------------------------------- *//* Dependencies */#ifndef _STRPORT_H#include <sys/strport.h> /* porting environment tailoring */#endif#ifndef _LIS_CONFIG_H#include <sys/strconfig.h> /* streams config symbols are here */#endif#ifndef _STR_MSG_H#include <sys/strmsg.h> /* streams msgs */#endif#ifndef _STR_OPTS_H#include <sys/stropts.h> /* streams operations */#endif#ifndef _MSG_H#include <sys/LiS/msg.h> /* streams msg symbols & types */#endif#ifndef _MSGUTL_H#include <sys/LiS/msgutl.h> /* streams msg utilities */#endif#ifndef _QUEUE_H#include <sys/LiS/queue.h> /* streams queue symbols & types */#endif#ifndef _EVENTS_H#include <sys/LiS/events.h> /* streams events */#endif#ifndef _MOD_H#include <sys/LiS/mod.h> /* streams module symbols & types */#endif#ifndef SYS_LISLOCKS_H#include <sys/lislocks.h> /* lis_semaphore_t, etc */#endif#include <sys/dki.h> /* toid_t */#if !defined(KERNEL_2_1)# ifndef _POLL_H# include <sys/LiS/poll.h> /* streams module symbols & types */# endif#endif/* ------------------------------------------------------------------- *//* Symbols *//* Close time max. */#define LIS_MAX_CLTIME 1000*60*5 /* in m.seconds -> 5min *//* Link time, default & max. */#define LIS_MAX_LNTIME 1000*60*5#define LIS_LNTIME 1000*15/* str head default high/low water marks */#define STRHIGH 5120#define STRLOW 1024/* str head flags */#define STWOPEN 0x00000001L /* someone's opening this */#define STFIFO 0x00000002L /* FIFO stream (or pipe end)? */#define STCONNLD 0x00000004L /* 'connld' pushed? */#define IOCWAIT 0x00000008L /* someone wants to do ioctl */#define STRCLOSE 0x00000010L /* stream is being closed */#define STRPLUMB 0x00000020L /*!push/pop pending */#define STRHOLD 0x00000040L /* use stream hold on write feature */#define STRATTACH 0x00000080L /* stream has been fattach'ed */#define STREOPEN 0x00000100L /* stream can be reopened (uses sd_from) */#define STPLEX 0x00001000L /* multiplexed stream */#define STRISTTY 0x00002000L /* stream is a terminal */#define STRTOSTOP 0x00004000L /* block background writes */#define STRSIGPIPE 0x00008000L /* send SIGPIPE on write errors */#define STRPRI 0x00010000L /* An M_PCPROTO is at stream head */#define STRDERR 0x00020000L /* fatal read error from M_ERROR */#define STWRERR 0x00040000L /* fatal write error from M_ERROR */#define STRHUP 0x00080000L /* Device has vanished */#define SNDMREAD 0x00100000L /* used for read notification */#define OLDNDELAY 0x00200000L /* use old TTY semantics for */ /* NDELAY reads and writes */#define STRDELIM 0x00400000L /* generate delimited messages ???*/#define STRSELPND 0x00800000L /* select waiting on this stream */#define STIOCTMR 0x01000000L /* ioctl timer in progress */#define STRCLOSEWT 0x02000000L /* waiting on sd_close_wt sem */#define STRFLUSHWT 0x04000000L /* waiting on sd_close_wt sem for flush *//* ------------------------------------------------------------------- *//* Should be in head->magic, it's used to cach 254/255 ;) * dangling references to a stream heads in critical places */#define STDATA_MAGIC (0x11110000L | sizeof(stdata_t))/* ------------------------------------------------------------------- *//* Types *//* * This structure is embedded in the stdata struct. It is used for * maintaining the topology of multiplexors. When the user does * an ioctl(fd, I_LINK, muxfd), the stream represented by muxfd * is linked "below" the stream driver represented by fd. The * stdata struct of fd uses mx_hd as a list head to thread together * all such streams that were linked below it. The mx_next field * carries the links. * * The muxfd stream is marked as belonging to a multiplexor and * cannot be operated on with file I/O routines, except close. * * The muxfd stream has its refcnt incremented so that if it is * closed it will not be deallocated. * * When it is time to unlink the stream it is removed from its list. * The refcnt is then decremented and if it reaches zero the stream * is deallocated. * * If you close the stream that heads a list (a so-called "control stream") * then its list is traversed and each stream on the list is unlinked. * * The I_LINK ioctl returns a reference number, l_index, that is used * by the user to unlink the stream with ioctl(fd, I_UNLINK, l_index). * The list of streams headed by fd is scanned and the one with the * mx_index equal to l_index is unlinked. */#ifdef __KERNEL__typedef struct stmux{ int mx_cmd; /* I_LINK or I_PLINK */ int mx_index; /* l_index for this mux */ struct stdata *mx_hd; /* list head for control stream */ struct stdata *mx_next; /* list threaded through here */} stmux_t;#endif/* * The stdata struct. This is the main stream structure and is pointed * to by file pointers for the stream. It corresponds to the STREAM head. */#ifdef __KERNEL__#if defined(KERNEL_2_1)typedef struct{ uid_t uid ; uid_t euid ; uid_t suid ; uid_t fsuid ; gid_t gid ; gid_t egid ; gid_t sgid ; gid_t fsgid ; int ngroups ; gid_t groups[NGROUPS] ; kernel_cap_t cap_effective ; kernel_cap_t cap_inheritable ; kernel_cap_t cap_permitted ;} lis_kcreds_t ;#elsetypedef struct{ int dummy ;} lis_kcreds_t ;#endiftypedefstruct stdata{ long magic; /* should be always STDATA_MAGIC */ struct stdata *sd_next ; /* all stdatas are linked together */ struct stdata *sd_prev ; struct streamtab *sd_strtab; /* pointer to streamtab for stream */ struct queue *sd_wq; /* write queue */ struct stdata *sd_peer; /* other FIFO in a pipe */ struct inode *sd_inode; /* corresponding inode */#if defined(LINUX) && defined(KERNEL_2_3) struct dentry *sd_from; /* dentry->inode FIFO opened from */#else struct inode *sd_from; /* inode a FIFO was opened from */#endif struct file *sd_file; /* file being opened */ mblk_t *sd_wmsg; /* buff for write msg */ mblk_t *sd_iocblk; /* data block for ioctl */ mblk_t *sd_rput_hd; /* head of msgs from strrput */ mblk_t *sd_rput_tl; /* tail of that list */ int sd_open_flags ; /* flags that opened stream */ toid_t sd_scantimer; /* scanq timer handle */ int sd_iocseq; /* ioc seq # */ int sd_session; /* controlling session id */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -