📄 lis_register_strdev.9
字号:
'\" tr.\" -*- nroff -*-.\".\" @(#) lis_register_strdev.9,v 1.1.4.1 2004/01/12 23:33:06 brian Exp.\".\" =========================================================================.\".\" Copyright (C) 2001-2004 OpenSS7 Corp. <www.openss7.com>.\".\" All Rights Reserved..\".\" Permission is granted to make and distribute verbatim copies of this.\" manual provided the copyright notice and this permission notice are.\" preserved on all copies..\".\" Permission is granted to copy and distribute modified versions of this.\" manual under the conditions for verbatim copying, provided that the.\" entire resulting derived work is distributed under the terms of a.\" permission notice identical to this one.\" .\" Since the Linux kernel and libraries are constantly changing, this.\" manual page may be incorrect or out-of-date. The author(s) assume no.\" responsibility for errors or omissions, or for damages resulting from.\" the use of the information contained herein. The author(s) may not.\" have taken the same level of care in the production of this manual,.\" which is licensed free of charge, as they might when working.\" professionally..\" .\" Formatted or processed versions of this manual, if unaccompanied by.\" the source, must acknowledge the copyright and authors of this work..\".\" =========================================================================.\".\" Modified 2004/01/12 23:33:06 by brian.\".\" =========================================================================.so lis.macros.R1bracket-label "\fR[\fB" "\fR]" "\fR, \fB"no-default-databasedatabase lis.refsaccumulatemove-punctuationabbreviate Ajoin-authors ", " ", " " and "et-al " et al" 2 3abbreviate-label-ranges ".."sort-adjacent-labels.R2.\".\".TH LIS_REGISTER_STRDEV 9 "2004/01/12 23:33:06" "LiS-2_16_18-8" "Linux STREAMS DDI/DKI".SH NAME.B lis_register_strdev\- register a \fISTREAMS\fR device.SH SYNOPSIS.PP.B #include <sys/stream.h>.HP 8.BI "int " retval " = lis_register_strdev(major_t " major ", struct streamtab *" strtab ", int " nminor ", const char *" name );.SH DESCRIPTION.PP.BR lis_register_strdev ()allocates a major device number andregisters a new.IR STREAMS (4)device with the.B Linuxkernel against that major devicenumber.Once a.IR STREAMS (4)device is registered, opening a device with the registered major device numberwill result in a call to the.IR STREAMS (4)driver's open routine..PP.BR lis_register_strdev ()is an LiS-specific function..[LiS.].IR STREAMS (4)devices registered with.BR lis_register_strdev ()can be deregistered with.BR lis_unregister_strdev (9)..PP.BR lis_register_strdev ()registers the.IR STREAMS (4)device with the.B streamtabstructure pointed to by.I strtaband the name pointed to by.IR name .When.I majoris specified as zero (0),.BR lis_register_strdev ()will attempt to assign a major device number to the device.When.I majoris non-zero,.BR lis_regsiter_strdev ()will attempt to use the major device number specified by.IR major ..PP.BR lis_register_strdev ()uses the.B Linuxkernel function.BR register_chrdev ()to register the character special device..PP.BR lis_register_strdev ()ignores the.I nminorargument. This argument used to allocate a range of minors in previousversions of LiS,.[LiS.]but is no longer used..SS "Linux Kernel Module Loading".PP.B Linuxhas the feature that if a character major device is unassigned and an attemptis made to open a character device with the major device number, the.B Linuxkernel will attempt to load the kernel module\fB\)char-major-\fI\)XXX\fR\),where.I XXXis the ascii major device number..PPThis is a feature of.B Linuxand is not specific to.B LiS\c..[LiS.].SH "RETURN VALUES".PPUpon success,.BR lis_register_strdev ()returns a positive integer representing the major device number assigned tothe.IR STREAMS (4)device..PPUpon failure,.BR lis_register_strdev ()returns a negative error number..SH ERRORS.PPWhen.BR lis_regsister_strdev ()fails it returns the negative of one of the following errors:.TP.RB [ EIO ]The device major number specified by.I majorcould not be assigned; or, if.I majorwas zero, a new major device number could not be assigned..TP.RB [ EINVAL ]The.B streamtabpointer.I strtabis.BR NULL ..TP.RB [ EBUSY ]The specified major device number is already in use by another.IR STREAMS (4)character special device..SH CAVEATS.PP.B LiS.[LiS.]uses a fixed size switch table to contain registered devices.is .SH EXAMPLES.PPThe following example demonstrates how 4 major device numbers could beregistered against a.IR STREAMS (4)driver:.sp.in +4.nf\fC\s-2\#define X_MAJOR 222#define X_NMAJOR 4#define X_NMINOR 255#define X_DRV_NAME "example"int x_initialized = 0;ushort x_majors[X_NMAJOR] = { X_CMAJOR, };void x_init(void){ int err, mindex; for (mindex = 0; mindex < X_NMAJOR; mindex++) { if ((err = lis_register_strdev(x_majors[mindex], &x_info, X_NMINOR, X_DRV_NAME)) < 0) { if (!mindex) { cmn_err(CE_PANIC, "%s: could not register 1'st major %d", X_DRV_NAME, x_majors[mindex]); x_initialized = err; return; } cmn_err(CE_WARN, "%s: could not register %d'th major", X_DRV_NAME, mindex + 1); x_majors[mindex] = 0; } else if (mindex) x_majors[mindex] = err; } x_initialized = 1; return;}void x_terminate(void){ int err, mindex; for (mindex = 0; mindex < X_NMAJOR; mindex++) { if (x_majors[mindex]) { if ((err = lis_unregister_strdev(x_majors[mindex]))) cmn_err(CE_PANIC, "%s: could not unregister major %d", X_DRV_NAME, x_majors[mindex]); if (mindex) x_majors[mindex] = 0; } } return;}\s+2\fR.fi.PPWhere the example above is compiled into a.B Linuxkernel module named\fB\)streams-\fI\)x\fB\).o\fR\),placing a line such as follows in the.BR /etc/modules.conf " or " /etc/conf.modulesfile will cause the.B Linuxkernel to load the streams module on demand..sp.in +4.nf\fC\s-2\alias char-major-222 streams-x # demand load streams device x\s+2\fR.fi.B .SH FILES.B /etc/conf.modules.br.B /etc/modules.conf.SH "SEE ALSO".PP.BR lis_register_strmod (9),.BR lis_unregister_strdev (9),.BR lis_unregister_strmod (9)..\".\".XX.[magic.].[svr42.].[svr4.].\".\".[$LIST$.].TA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -