xref: /freebsd/lib/libcam/cam.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
101a4eb82SKenneth D. Merry.\"
201a4eb82SKenneth D. Merry.\" Copyright (c) 1998 Kenneth D. Merry.
301a4eb82SKenneth D. Merry.\" All rights reserved.
401a4eb82SKenneth D. Merry.\"
501a4eb82SKenneth D. Merry.\" Redistribution and use in source and binary forms, with or without
601a4eb82SKenneth D. Merry.\" modification, are permitted provided that the following conditions
701a4eb82SKenneth D. Merry.\" are met:
801a4eb82SKenneth D. Merry.\" 1. Redistributions of source code must retain the above copyright
901a4eb82SKenneth D. Merry.\"    notice, this list of conditions and the following disclaimer.
1001a4eb82SKenneth D. Merry.\" 2. Redistributions in binary form must reproduce the above copyright
1101a4eb82SKenneth D. Merry.\"    notice, this list of conditions and the following disclaimer in the
1201a4eb82SKenneth D. Merry.\"    documentation and/or other materials provided with the distribution.
1301a4eb82SKenneth D. Merry.\" 3. The name of the author may not be used to endorse or promote products
1401a4eb82SKenneth D. Merry.\"    derived from this software without specific prior written permission.
1501a4eb82SKenneth D. Merry.\"
1601a4eb82SKenneth D. Merry.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1701a4eb82SKenneth D. Merry.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1801a4eb82SKenneth D. Merry.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1901a4eb82SKenneth D. Merry.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2001a4eb82SKenneth D. Merry.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2101a4eb82SKenneth D. Merry.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2201a4eb82SKenneth D. Merry.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2301a4eb82SKenneth D. Merry.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2401a4eb82SKenneth D. Merry.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2501a4eb82SKenneth D. Merry.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2601a4eb82SKenneth D. Merry.\" SUCH DAMAGE.
2701a4eb82SKenneth D. Merry.\"
28*409594efSTom Hukins.Dd June 1, 2023
2901a4eb82SKenneth D. Merry.Dt CAM 3
30aa12cea2SUlrich Spörlein.Os
3101a4eb82SKenneth D. Merry.Sh NAME
3201a4eb82SKenneth D. Merry.Nm cam_open_device ,
3301a4eb82SKenneth D. Merry.Nm cam_open_spec_device ,
3401a4eb82SKenneth D. Merry.Nm cam_open_btl ,
3501a4eb82SKenneth D. Merry.Nm cam_open_pass ,
3601a4eb82SKenneth D. Merry.Nm cam_close_device ,
3701a4eb82SKenneth D. Merry.Nm cam_close_spec_device ,
3801a4eb82SKenneth D. Merry.Nm cam_getccb ,
3901a4eb82SKenneth D. Merry.Nm cam_send_ccb ,
4001a4eb82SKenneth D. Merry.Nm cam_freeccb ,
4101a4eb82SKenneth D. Merry.Nm cam_path_string ,
4201a4eb82SKenneth D. Merry.Nm cam_device_dup ,
4301a4eb82SKenneth D. Merry.Nm cam_device_copy ,
4401a4eb82SKenneth D. Merry.Nm cam_get_device
4501a4eb82SKenneth D. Merry.Nd CAM user library
46c8baaf18SAlexey Zelkin.Sh LIBRARY
47c8baaf18SAlexey Zelkin.Lb libcam
4801a4eb82SKenneth D. Merry.Sh SYNOPSIS
4932eef9aeSRuslan Ermilov.In stdio.h
5032eef9aeSRuslan Ermilov.In camlib.h
5101a4eb82SKenneth D. Merry.Ft struct cam_device *
5201a4eb82SKenneth D. Merry.Fo cam_open_device
5301a4eb82SKenneth D. Merry.Fa "const char *path"
5401a4eb82SKenneth D. Merry.Fa "int flags"
5501a4eb82SKenneth D. Merry.Fc
5601a4eb82SKenneth D. Merry.Ft struct cam_device *
5701a4eb82SKenneth D. Merry.Fo cam_open_spec_device
5801a4eb82SKenneth D. Merry.Fa "const char *dev_name"
5901a4eb82SKenneth D. Merry.Fa "int unit"
6001a4eb82SKenneth D. Merry.Fa "int flags"
6101a4eb82SKenneth D. Merry.Fa "struct cam_device *device"
6201a4eb82SKenneth D. Merry.Fc
6301a4eb82SKenneth D. Merry.Ft struct cam_device *
6401a4eb82SKenneth D. Merry.Fo cam_open_btl
6501a4eb82SKenneth D. Merry.Fa "path_id_t path_id"
6601a4eb82SKenneth D. Merry.Fa "target_id_t target_id"
6701a4eb82SKenneth D. Merry.Fa "lun_id_t target_lun"
6801a4eb82SKenneth D. Merry.Fa "int flags"
6901a4eb82SKenneth D. Merry.Fa "struct cam_device *device"
7001a4eb82SKenneth D. Merry.Fc
7101a4eb82SKenneth D. Merry.Ft struct cam_device *
7201a4eb82SKenneth D. Merry.Fo cam_open_pass
7301a4eb82SKenneth D. Merry.Fa "const char *path"
7401a4eb82SKenneth D. Merry.Fa "int flags"
7501a4eb82SKenneth D. Merry.Fa "struct cam_device *device"
7601a4eb82SKenneth D. Merry.Fc
7701a4eb82SKenneth D. Merry.Ft void
7801a4eb82SKenneth D. Merry.Fo cam_close_device
7901a4eb82SKenneth D. Merry.Fa "struct cam_device *dev"
8001a4eb82SKenneth D. Merry.Fc
8101a4eb82SKenneth D. Merry.Ft void
8201a4eb82SKenneth D. Merry.Fo cam_close_spec_device
8301a4eb82SKenneth D. Merry.Fa "struct cam_device *dev"
8401a4eb82SKenneth D. Merry.Fc
8501a4eb82SKenneth D. Merry.Ft union ccb *
8601a4eb82SKenneth D. Merry.Fo cam_getccb
8701a4eb82SKenneth D. Merry.Fa "struct cam_device *dev"
8801a4eb82SKenneth D. Merry.Fc
8901a4eb82SKenneth D. Merry.Ft int
9001a4eb82SKenneth D. Merry.Fo cam_send_ccb
9101a4eb82SKenneth D. Merry.Fa "struct cam_device *device"
9201a4eb82SKenneth D. Merry.Fa "union ccb *ccb"
9301a4eb82SKenneth D. Merry.Fc
9401a4eb82SKenneth D. Merry.Ft void
9501a4eb82SKenneth D. Merry.Fo cam_freeccb
9601a4eb82SKenneth D. Merry.Fa "union ccb *ccb"
9701a4eb82SKenneth D. Merry.Fc
9801a4eb82SKenneth D. Merry.Ft char *
9901a4eb82SKenneth D. Merry.Fo cam_path_string
10001a4eb82SKenneth D. Merry.Fa "struct cam_device *dev"
10101a4eb82SKenneth D. Merry.Fa "char *str"
10201a4eb82SKenneth D. Merry.Fa "int len"
10301a4eb82SKenneth D. Merry.Fc
10401a4eb82SKenneth D. Merry.Ft struct cam_device *
10501a4eb82SKenneth D. Merry.Fo cam_device_dup
10601a4eb82SKenneth D. Merry.Fa "struct cam_device *device"
10701a4eb82SKenneth D. Merry.Fc
10801a4eb82SKenneth D. Merry.Ft void
10901a4eb82SKenneth D. Merry.Fo cam_device_copy
11001a4eb82SKenneth D. Merry.Fa "struct cam_device *src"
11101a4eb82SKenneth D. Merry.Fa "struct cam_device *dst"
11201a4eb82SKenneth D. Merry.Fc
11301a4eb82SKenneth D. Merry.Ft int
11401a4eb82SKenneth D. Merry.Fo cam_get_device
11501a4eb82SKenneth D. Merry.Fa "const char *path"
11601a4eb82SKenneth D. Merry.Fa "char *dev_name"
11701a4eb82SKenneth D. Merry.Fa "int devnamelen"
11801a4eb82SKenneth D. Merry.Fa "int *unit"
11901a4eb82SKenneth D. Merry.Fc
12001a4eb82SKenneth D. Merry.Sh DESCRIPTION
12101a4eb82SKenneth D. MerryThe CAM library consists of a number of functions designed to aid in
1223e1af044STom Hukinsprogramming with the CAM subsystem described in
1233e1af044STom Hukins.Xr cam 4 .
1241a0a9345SRuslan ErmilovThis man page covers the basic set of
1251a0a9345SRuslan Ermilovlibrary functions.
1261a0a9345SRuslan ErmilovMore functions are documented in the man pages listed
12701a4eb82SKenneth D. Merrybelow.
12801a4eb82SKenneth D. Merry.Pp
12901a4eb82SKenneth D. MerryMany of the CAM library functions use the
13001a4eb82SKenneth D. Merry.Va cam_device
13101a4eb82SKenneth D. Merrystructure:
13201a4eb82SKenneth D. Merry.Bd -literal
13301a4eb82SKenneth D. Merrystruct cam_device {
13401a4eb82SKenneth D. Merry	char		device_path[MAXPATHLEN+1];/*
13501a4eb82SKenneth D. Merry						   * Pathname of the
13601a4eb82SKenneth D. Merry						   * device given by the
13701a4eb82SKenneth D. Merry						   * user. This may be
13801a4eb82SKenneth D. Merry						   * null if the user
13901a4eb82SKenneth D. Merry						   * states the device
14001a4eb82SKenneth D. Merry						   * name and unit number
14101a4eb82SKenneth D. Merry						   * separately.
14201a4eb82SKenneth D. Merry						   */
14301a4eb82SKenneth D. Merry	char		given_dev_name[DEV_IDLEN+1];/*
14401a4eb82SKenneth D. Merry						     * Device name given by
14501a4eb82SKenneth D. Merry						     * the user.
14601a4eb82SKenneth D. Merry						     */
1476b99842aSEd Schouten	uint32_t	given_unit_number;	    /*
14801a4eb82SKenneth D. Merry						     * Unit number given by
14901a4eb82SKenneth D. Merry						     * the user.
15001a4eb82SKenneth D. Merry						     */
15101a4eb82SKenneth D. Merry	char		device_name[DEV_IDLEN+1];/*
15201a4eb82SKenneth D. Merry						  * Name of the device,
153acdb1504SEnji Cooper						  * e.g., 'pass'
15401a4eb82SKenneth D. Merry						  */
1556b99842aSEd Schouten	uint32_t	dev_unit_num;	/* Unit number of the passthrough
15601a4eb82SKenneth D. Merry					 * device associated with this
15701a4eb82SKenneth D. Merry					 * particular device.
15801a4eb82SKenneth D. Merry					 */
15901a4eb82SKenneth D. Merry
16001a4eb82SKenneth D. Merry	char		sim_name[SIM_IDLEN+1];/*
161acdb1504SEnji Cooper					       * Controller name, e.g., 'ahc'
16201a4eb82SKenneth D. Merry					       */
1636b99842aSEd Schouten	uint32_t	sim_unit_number; /* Controller unit number */
1646b99842aSEd Schouten	uint32_t	bus_id;		 /* Controller bus number */
16501a4eb82SKenneth D. Merry	lun_id_t	target_lun;	 /* Logical Unit Number */
16601a4eb82SKenneth D. Merry	target_id_t	target_id;	 /* Target ID */
16701a4eb82SKenneth D. Merry	path_id_t	path_id;	 /* System SCSI bus number */
1686b99842aSEd Schouten	uint16_t	pd_type;	 /* type of peripheral device */
16901a4eb82SKenneth D. Merry	struct scsi_inquiry_data inq_data;  /* SCSI Inquiry data */
1706b99842aSEd Schouten	uint8_t		serial_num[252]; /* device serial number */
1716b99842aSEd Schouten	uint8_t		serial_num_len;  /* length of the serial number */
1726b99842aSEd Schouten	uint8_t		sync_period;	 /* Negotiated sync period */
1736b99842aSEd Schouten	uint8_t		sync_offset;	 /* Negotiated sync offset */
1746b99842aSEd Schouten	uint8_t		bus_width;	 /* Negotiated bus width */
17501a4eb82SKenneth D. Merry	int		fd;		 /* file descriptor for device */
17601a4eb82SKenneth D. Merry};
17701a4eb82SKenneth D. Merry.Ed
17801a4eb82SKenneth D. Merry.Pp
17901a4eb82SKenneth D. Merry.Fn cam_open_device
18001a4eb82SKenneth D. Merrytakes as arguments a string describing the device it is to open, and
18101a4eb82SKenneth D. Merry.Ar flags
18201a4eb82SKenneth D. Merrysuitable for passing to
18301a4eb82SKenneth D. Merry.Xr open 2 .
18401a4eb82SKenneth D. MerryThe "path" passed in may actually be most any type of string that contains
1851a0a9345SRuslan Ermilova device name and unit number to be opened.
1861a0a9345SRuslan ErmilovThe string will be parsed by
18701a4eb82SKenneth D. Merry.Fn cam_get_device
1881a0a9345SRuslan Ermilovinto a device name and unit number.
1891a0a9345SRuslan ErmilovOnce the device name and unit number
19001a4eb82SKenneth D. Merryare determined, a lookup is performed to determine the passthrough device
19101a4eb82SKenneth D. Merrythat corresponds to the given device.
19201a4eb82SKenneth D. Merry.Pp
19301a4eb82SKenneth D. Merry.Fn cam_open_spec_device
19401a4eb82SKenneth D. Merryopens the
19501a4eb82SKenneth D. Merry.Xr pass 4
1961a0a9345SRuslan Ermilovdevice that corresponds to the device name and unit number passed in.
1971a0a9345SRuslan ErmilovThe
19801a4eb82SKenneth D. Merry.Ar flags
19901a4eb82SKenneth D. Merryshould be flags suitable for passing to
20001a4eb82SKenneth D. Merry.Xr open 2 .
20101a4eb82SKenneth D. MerryThe
20201a4eb82SKenneth D. Merry.Ar device
2031a0a9345SRuslan Ermilovargument is optional.
2041a0a9345SRuslan ErmilovThe user may supply pre-allocated space for the
20501a4eb82SKenneth D. Merry.Va cam_device
2061a0a9345SRuslan Ermilovstructure.
2071a0a9345SRuslan ErmilovIf the
20801a4eb82SKenneth D. Merry.Ar device
20901a4eb82SKenneth D. Merryargument is
21088cbf292SEnji Cooper.Dv NULL ,
21101a4eb82SKenneth D. Merry.Fn cam_open_spec_device
21201a4eb82SKenneth D. Merrywill allocate space for the
21301a4eb82SKenneth D. Merry.Va cam_device
21401a4eb82SKenneth D. Merrystructure using
21501a4eb82SKenneth D. Merry.Xr malloc 3 .
21601a4eb82SKenneth D. Merry.Pp
21701a4eb82SKenneth D. Merry.Fn cam_open_btl
21801a4eb82SKenneth D. Merryis similar to
21901a4eb82SKenneth D. Merry.Fn cam_open_spec_device ,
220bd93bdc9SMateusz Piotrowskiexcept that it takes a SCSI bus,
221bd93bdc9SMateusz Piotrowskitarget and logical unit instead of a device name and unit number as
2221a0a9345SRuslan Ermilovarguments.
2231a0a9345SRuslan ErmilovThe
22401a4eb82SKenneth D. Merry.Va path_id
225bd93bdc9SMateusz Piotrowskiargument is the CAM equivalent of a SCSI bus number.
2261a0a9345SRuslan ErmilovIt represents the logical bus number in the system.
2271a0a9345SRuslan ErmilovThe
22801a4eb82SKenneth D. Merry.Ar flags
22901a4eb82SKenneth D. Merryshould be flags suitable for passing to
23001a4eb82SKenneth D. Merry.Xr open 2 .
23101a4eb82SKenneth D. MerryAs with
23201a4eb82SKenneth D. Merry.Fn cam_open_spec_device ,
23301a4eb82SKenneth D. Merrythe
23401a4eb82SKenneth D. Merry.Fa device
23501a4eb82SKenneth D. Merryargument is optional.
23601a4eb82SKenneth D. Merry.Pp
23701a4eb82SKenneth D. Merry.Fn cam_open_pass
23801a4eb82SKenneth D. Merrytakes as an argument the
23901a4eb82SKenneth D. Merry.Fa path
24001a4eb82SKenneth D. Merryof a
24101a4eb82SKenneth D. Merry.Xr pass 4
2421a0a9345SRuslan Ermilovdevice to open.
2431a0a9345SRuslan ErmilovNo translation or lookup is performed, so the path passed
24401a4eb82SKenneth D. Merryin must be that of a CAM
24501a4eb82SKenneth D. Merry.Xr pass 4
2461a0a9345SRuslan Ermilovdevice.
2471a0a9345SRuslan ErmilovThe
24801a4eb82SKenneth D. Merry.Fa flags
24901a4eb82SKenneth D. Merryshould be flags suitable for passing to
25001a4eb82SKenneth D. Merry.Xr open 2 .
25101a4eb82SKenneth D. MerryThe
25201a4eb82SKenneth D. Merry.Fa device
25301a4eb82SKenneth D. Merryargument, as with
25401a4eb82SKenneth D. Merry.Fn cam_open_spec_device
25501a4eb82SKenneth D. Merryand
25601a4eb82SKenneth D. Merry.Fn cam_open_btl ,
25788cbf292SEnji Coopershould be
25888cbf292SEnji Cooper.Dv NULL
25988cbf292SEnji Cooperif the user wants the CAM library to allocate space for the
26001a4eb82SKenneth D. Merry.Va cam_device
26101a4eb82SKenneth D. Merrystructure.
262bd93bdc9SMateusz Piotrowski.Pp
26301a4eb82SKenneth D. Merry.Fn cam_close_device
26401a4eb82SKenneth D. Merryfrees the
26501a4eb82SKenneth D. Merry.Va cam_device
266bd93bdc9SMateusz Piotrowskistructure allocated by one of the above
267bd93bdc9SMateusz Piotrowski.Xr open 2
268bd93bdc9SMateusz Piotrowskicalls, and closes the file
2691a0a9345SRuslan Ermilovdescriptor to the passthrough device.
2701a0a9345SRuslan ErmilovThis routine should not be called if
27101a4eb82SKenneth D. Merrythe user allocated space for the
27201a4eb82SKenneth D. Merry.Va cam_device
2731a0a9345SRuslan Ermilovstructure.
2741a0a9345SRuslan ErmilovInstead, the user should call
27501a4eb82SKenneth D. Merry.Fn cam_close_spec_device .
27601a4eb82SKenneth D. Merry.Pp
27701a4eb82SKenneth D. Merry.Fn cam_close_spec_device
278bd93bdc9SMateusz Piotrowskimerely closes the file descriptor opened in one of the
279bd93bdc9SMateusz Piotrowski.Xr open 2
280bd93bdc9SMateusz Piotrowskiroutines
2811a0a9345SRuslan Ermilovdescribed above.
2821a0a9345SRuslan ErmilovThis function should be called when the
28301a4eb82SKenneth D. Merry.Va cam_device
28401a4eb82SKenneth D. Merrystructure was allocated by the caller, rather than the CAM library.
28501a4eb82SKenneth D. Merry.Pp
28601a4eb82SKenneth D. Merry.Fn cam_getccb
2873e404b8cSEdward Tomasz Napieralaallocates a prezeroed CCB
28801a4eb82SKenneth D. Merryusing
2893e404b8cSEdward Tomasz Napierala.Xr calloc 3
29001a4eb82SKenneth D. Merryand sets fields in the CCB header using values from the
29101a4eb82SKenneth D. Merry.Va cam_device
29201a4eb82SKenneth D. Merrystructure.
29301a4eb82SKenneth D. Merry.Pp
29401a4eb82SKenneth D. Merry.Fn cam_send_ccb
29501a4eb82SKenneth D. Merrysends the given
29601a4eb82SKenneth D. Merry.Va ccb
29701a4eb82SKenneth D. Merryto the
29801a4eb82SKenneth D. Merry.Fa device
29901a4eb82SKenneth D. Merrydescribed in the
30001a4eb82SKenneth D. Merry.Va cam_device
30101a4eb82SKenneth D. Merrystructure.
30201a4eb82SKenneth D. Merry.Pp
30301a4eb82SKenneth D. Merry.Fn cam_freeccb
30401a4eb82SKenneth D. Merryfrees CCBs allocated by
30501a4eb82SKenneth D. Merry.Fn cam_getccb .
306c876175cSEnji CooperIf
307c876175cSEnji Cooper.Va ccb
308c876175cSEnji Cooperis
309c876175cSEnji Cooper.Dv NULL ,
310c876175cSEnji Cooperno action is taken.
31101a4eb82SKenneth D. Merry.Pp
31201a4eb82SKenneth D. Merry.Fn cam_path_string
31301a4eb82SKenneth D. Merrytakes as arguments a
31401a4eb82SKenneth D. Merry.Va cam_device
31501a4eb82SKenneth D. Merrystructure, and a string with length
31601a4eb82SKenneth D. Merry.Fa len .
31701a4eb82SKenneth D. MerryIt creates a colon-terminated printing prefix string similar to the ones
3181a0a9345SRuslan Ermilovused by the kernel.
3191a0a9345SRuslan Ermilove.g.: "(cd0:ahc1:0:4:0): ".
32001a4eb82SKenneth D. Merry.Fn cam_path_string
32101a4eb82SKenneth D. Merrywill place at most
32201a4eb82SKenneth D. Merry.Fa len Ns \-1
32301a4eb82SKenneth D. Merrycharacters into
32401a4eb82SKenneth D. Merry.Ar str .
32501a4eb82SKenneth D. MerryThe
32601a4eb82SKenneth D. Merry.Ar len Ns 'th
32701a4eb82SKenneth D. Merrycharacter will be the terminating
32801a4eb82SKenneth D. Merry.Ql \e0 .
32901a4eb82SKenneth D. Merry.Pp
33001a4eb82SKenneth D. Merry.Fn cam_device_dup
33101a4eb82SKenneth D. Merryoperates in a fashion similar to
33201a4eb82SKenneth D. Merry.Xr strdup 3 .
33301a4eb82SKenneth D. MerryIt allocates space for a
33401a4eb82SKenneth D. Merry.Va cam_device
33501a4eb82SKenneth D. Merrystructure and copies the contents of the passed-in
33601a4eb82SKenneth D. Merry.Fa device
33701a4eb82SKenneth D. Merrystructure to the newly allocated structure.
33801a4eb82SKenneth D. Merry.Pp
33901a4eb82SKenneth D. Merry.Fn cam_device_copy
34001a4eb82SKenneth D. Merrycopies the
34101a4eb82SKenneth D. Merry.Fa src
34201a4eb82SKenneth D. Merrystructure to
34301a4eb82SKenneth D. Merry.Fa dst .
34401a4eb82SKenneth D. Merry.Pp
34501a4eb82SKenneth D. Merry.Fn cam_get_device
34601a4eb82SKenneth D. Merrytakes a
34701a4eb82SKenneth D. Merry.Fa path
34801a4eb82SKenneth D. Merryargument containing a string with a device name followed by a unit number.
34901a4eb82SKenneth D. MerryIt then breaks the string down into a device name and unit number, and
35001a4eb82SKenneth D. Merrypasses them back in
35101a4eb82SKenneth D. Merry.Fa dev_name
35201a4eb82SKenneth D. Merryand
35301a4eb82SKenneth D. Merry.Fa unit ,
35401a4eb82SKenneth D. Merryrespectively.
35501a4eb82SKenneth D. Merry.Fn cam_get_device
35601a4eb82SKenneth D. Merrycan handle strings of the following forms, at least:
35701a4eb82SKenneth D. Merry.Pp
35801a4eb82SKenneth D. Merry.Bl -tag -width 1234 -compact
3595bcc8fafSAndriy Gapon.It /dev/foo1
36001a4eb82SKenneth D. Merry.It foo0
3615bcc8fafSAndriy Gapon.It nsa2
36201a4eb82SKenneth D. Merry.El
36301a4eb82SKenneth D. Merry.Pp
36401a4eb82SKenneth D. Merry.Fn cam_get_device
36501a4eb82SKenneth D. Merryis provided as a convenience function for applications that need to provide
36601a4eb82SKenneth D. Merryfunctionality similar to
36701a4eb82SKenneth D. Merry.Fn cam_open_device .
36801a4eb82SKenneth D. Merry.Sh RETURN VALUES
36901a4eb82SKenneth D. Merry.Fn cam_open_device ,
37001a4eb82SKenneth D. Merry.Fn cam_open_spec_device ,
37101a4eb82SKenneth D. Merry.Fn cam_open_btl ,
37201a4eb82SKenneth D. Merryand
37301a4eb82SKenneth D. Merry.Fn cam_open_pass
37401a4eb82SKenneth D. Merryreturn a pointer to a
37501a4eb82SKenneth D. Merry.Va cam_device
37688cbf292SEnji Cooperstructure, or
37788cbf292SEnji Cooper.Dv NULL
37888cbf292SEnji Cooperif there was an error.
37901a4eb82SKenneth D. Merry.Pp
38001a4eb82SKenneth D. Merry.Fn cam_getccb
38188cbf292SEnji Cooperreturns an allocated and partially initialized CCB, or
38288cbf292SEnji Cooper.Dv NULL
38388cbf292SEnji Cooperif allocation of the CCB failed.
38401a4eb82SKenneth D. Merry.Pp
38501a4eb82SKenneth D. Merry.Fn cam_send_ccb
386f6ac2391SJoel Dahlreturns a value of -1 if an error occurred, and
38701a4eb82SKenneth D. Merry.Va errno
38801a4eb82SKenneth D. Merryis set to indicate the error.
38901a4eb82SKenneth D. Merry.Pp
39001a4eb82SKenneth D. Merry.Fn cam_path_string
3911a0a9345SRuslan Ermilovreturns a filled printing prefix string as a convenience.
3921a0a9345SRuslan ErmilovThis is the same
39301a4eb82SKenneth D. Merry.Fa str
39401a4eb82SKenneth D. Merrythat is passed into
39501a4eb82SKenneth D. Merry.Fn cam_path_string .
39601a4eb82SKenneth D. Merry.Pp
39701a4eb82SKenneth D. Merry.Fn cam_device_dup
39801a4eb82SKenneth D. Merryreturns a copy of the
39901a4eb82SKenneth D. Merry.Va device
40088cbf292SEnji Cooperpassed in, or
40188cbf292SEnji Cooper.Dv NULL
40288cbf292SEnji Cooperif an error occurred.
40301a4eb82SKenneth D. Merry.Pp
40401a4eb82SKenneth D. Merry.Fn cam_get_device
40501a4eb82SKenneth D. Merryreturns 0 for success, and -1 to indicate failure.
40601a4eb82SKenneth D. Merry.Pp
40701a4eb82SKenneth D. MerryIf an error is returned from one of the base CAM library functions
40801a4eb82SKenneth D. Merrydescribed here, the reason for the error is generally printed in the global
40901a4eb82SKenneth D. Merrystring
41001a4eb82SKenneth D. Merry.Va cam_errbuf
41101a4eb82SKenneth D. Merrywhich is
41201a4eb82SKenneth D. Merry.Dv CAM_ERRBUF_SIZE
41301a4eb82SKenneth D. Merrycharacters long.
41401a4eb82SKenneth D. Merry.Sh SEE ALSO
41501a4eb82SKenneth D. Merry.Xr cam_cdbparse 3 ,
41601a4eb82SKenneth D. Merry.Xr pass 4 ,
41774804d58SMike Pritchard.Xr camcontrol 8
41801a4eb82SKenneth D. Merry.Sh HISTORY
41901a4eb82SKenneth D. MerryThe CAM library first appeared in
42001a4eb82SKenneth D. Merry.Fx 3.0 .
42101a4eb82SKenneth D. Merry.Sh AUTHORS
4222b7af31cSBaptiste Daroussin.An Kenneth Merry Aq Mt ken@FreeBSD.org
42301a4eb82SKenneth D. Merry.Sh BUGS
42401a4eb82SKenneth D. Merry.Fn cam_open_device
4250227791bSRuslan Ermilovdoes not check to see if the
42601a4eb82SKenneth D. Merry.Fa path
4271a0a9345SRuslan Ermilovpassed in is a symlink to something.
4280227791bSRuslan ErmilovIt also does not check to see if the
42901a4eb82SKenneth D. Merry.Fa path
43001a4eb82SKenneth D. Merrypassed in is an actual
43101a4eb82SKenneth D. Merry.Xr pass 4
4321a0a9345SRuslan Ermilovdevice.
4331a0a9345SRuslan ErmilovThe former would be rather easy to implement, but the latter would
43401a4eb82SKenneth D. Merryrequire a definitive way to identify a device node as a
43501a4eb82SKenneth D. Merry.Xr pass 4
43601a4eb82SKenneth D. Merrydevice.
43701a4eb82SKenneth D. Merry.Pp
438acdb1504SEnji CooperSome of the functions are possibly misnamed or poorly named.
439