MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers                  ldiopenbydev(9F)



NAME
     ldiopenbydev,    ldiopenbyname,     ldiopenbydevid,
     ldiclose - open and close devices

SYNOPSIS
     #include 

     int ldiopenbydev(devt *devp, int otyp, int flag, credt  *cr,
          ldihandlet *lhp, ldiidentt li);


     int ldiopenbyname(char  *pathname, int flag, credt *cr,
          ldihandlet *lhp, ldiidentt li);


     int ldiopenbydevid(ddidevidt devid, char  *minorname, int flag,
          credt *cr, ldihandlet *lhp, ldiidentt li);


     int ldiclose(ldihandlet lh, int flag, cred t *cr);


PARAMETERS
     lh            Layered handle


     lhp           Pointer to a layered handle that  is  returned
                   upon a successful open.


     li            LDI identifier.


     cr            Pointer to the credential  structure  used  to
                   open a device.


     devp          Pointer to a device number.


     pathname      Pathname to a device.


     devid         Device ID.


     minorname    Minor device node name.


     otyp          Flag passed to  the  driver  indicating  which
                   interface is open. Valid settings are:




SunOS 5.11           Last change: 9 Aug 2004                    1






Kernel Functions for Drivers                  ldiopenbydev(9F)



                   OTYPBLK    Open the device block interface.


                   OTYPCHR    Open the device  character  inter-
                               face.

                   Only one OTYP flag can be specified.  To  open
                   streams devices, specify OTYPCHR.


     flag          Bit field that instructs the driver on how  to
                   open the device. Valid settings are:

                   FEXCL      Open  the  device  with   exclusive
                              access;  fail all other attempts to
                              open the device.


                   FNDELAY    Open the device and return  immedi-
                              ately.   Do not block the open even
                              if something is wrong.


                   FREAD      Open the device with read-only per-
                              mission.   (If  ORed  with  FWRITE,
                              allow both read and write access).


                   FWRITE     Open a device with write-only  per-
                              mission  (if  ORed with FREAD, then
                              allow both read and write access).


                   FNOCTY    Open the device. If the device is a
                              tty, do not attempt to open it as a
                              session-controlling tty.



DESCRIPTION
     The      ldiopenbydev(),      ldiopenbyname()      and
     ldiopenbydevid()  functions  allow  a  caller  to  open a
     block, character, or streams device. Upon a successful open,
     a  layered  handle to the device is returned via the layered
     handle pointed to by lhp. The ldi identifier passed to these
     functions       is       previously      allocated      with
     ldiidentfromstream(9F),    ldiidentfromdev(9F),    and
     ldiidentfromdip(9F).


     The ldiopenbydev() function opens a device  specified  by
     the  devt  pointed  to  by devp.  Upon successful open, the



SunOS 5.11           Last change: 9 Aug 2004                    2






Kernel Functions for Drivers                  ldiopenbydev(9F)



     caller should check the value of the devt to see if it  has
     changed.  (Cloning  devices  will  change  this value during
     opens.)   When  opening  a  streams  device,  otyp  must  be
     OTYPCHR.


     The ldiopenbydevid() function opens a  device  by  devid.
     The caller must specify the minor node name to open.


     The ldiopenbyname() function opens a device by  pathname.
     Pathname  is  a null terminated string in the kernel address
     space. Pathname must be an absolute path,  meaning  that  it
     must  begin with '/'. The format of the pathname supplied to
     this function  is  either  a  /devices  path  or  any  other
     filesystem  path  to a device node. Opens utilizing /devices
     paths are supported before root is mounted. Opens  utilizing
     other filesystem paths to device nodes are supported only if
     root is already mounted.


     The ldiclose() function closes a layered  handle  that  was
     obtained  with either ldiopenbydev(), ldiopenbyname(),
     or ldiopenbydevid(). After ldiclose() returns  the  lay-
     ered  handle,  the  lh  that  was previously passed in is no
     longer valid.

RETURN VALUES
     The ldiclose() function returns 0 for  success.  EINVAL  is
     returned  for invalid input parameters. Otherwise, any other
     error number may be returned by the device.


     The  ldiopenbydev()  and  ldiopenbydevid()   functions
     return 0 upon success. If a failure occurs before the device
     is open, possible return values are shown  below.  Otherwise
     any other error number may be returned by the device.

     EINVAL    Invalid input parameters.


     ENODEV    Requested device does not exist.


     ENXIO     Unsupported device operation or access mode.



     The ldiopenbyname() function returns 0 upon success. If a
     failure  occurs  before  the device is open, possible return
     values are shown below. Otherwise any other error number may
     be returned by the device.



SunOS 5.11           Last change: 9 Aug 2004                    3






Kernel Functions for Drivers                  ldiopenbydev(9F)



     EINVAL    Invalid input parameters.


     ENODEV    Requested device path does not exist.


     EACES    Search permission is denied on a component of  the
               path  prefix,  or  the file exists and the permis-
               sions specified by cr are denied.


     ENXIO     Unsupported device operation or access mode.


CONTEXT
     These functions may be called from user or kernel context.


     These functions should not be called from a device's attach,
     detach,  or power entry point. This could result in a system
     crash or deadlock.

SEE ALSO
     scsivhci(7D),                       ldiidentfromdev(9F),
     ldiidentfromdip(9F), ldiidentfromstream(9F)

NOTES
     Use only OTYPCHR or  OTYPBLK  options  when  you  use  the
     ldiopenbydev()  and ldiopenbydevid() functions to open
     a device. Other flags, including OTYPLYR, have been  depre-
     cated and should not be used with these interfaces.


     The caller should be aware of cases when multiple paths to a
     single device may exist.  (This can occur for scsi disk dev-
     ices if scsivhci(7D)) is disabled or a disk is connected to
     multiple controllers not supported by scsivhci(7D).


     In these cases, ldiopenbydevid() returns a device  handle
     that  corresponds  to a  particular path to a target device.
     This path may not be  the  same  across  multiple  calls  to
     ldiopenbydevid().   Device  handles  associated  with the
     same device but different access paths should have different
     filesystem device paths and devt values.


     In the cases where multiple paths  to  a  device  exist  and
     access  to the device has not been virtualized via MPXIO (as
     with scsi disk devices not accessed via scsivhci(7D)),  the
     LDI does not provide any path fail-over capabilities. If the
     caller wishes to do their own path management  and  failover



SunOS 5.11           Last change: 9 Aug 2004                    4






Kernel Functions for Drivers                  ldiopenbydev(9F)



     they  should  open  all  available  paths  to  a  device via
     ldiopenbyname().





















































SunOS 5.11           Last change: 9 Aug 2004                    5



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™