Commit Graph

20 Commits

Author SHA1 Message Date
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Andriy Gapon
84803238a8 camlib.c: update one overlooked comment 2010-10-11 21:34:35 +00:00
Andriy Gapon
5bcc8fafda cam_get_device, cam_open_device: make behavior simpler and more deterministic
Remove or re-work support for the several features from the past:
- remove incomplete support for trimming slice/partition names
- remove mapping from old device names "sd" and "st"
- remove whitespace trimming
- remove unconditional skipping of leading 'r' in a device name
- skip leading 'n' or 'e' only if the following device name matches
  a list of known devices that support no-rewind and eject-on-close
  features; currently this is only sa(4)
- reflect the above changes in comments in code and in cam(3)
- remove a note cautioning against use of cam_get_device and
  cam_open_device in cam(3)

Reviewed by:	mjacob
2010-10-11 09:27:37 +00:00
Marius Strobl
25ea4c843f Supply a valid Connect ID when issuing XPT_DEV_MATCH, which
according to my reading of the CAM draft is mandatory for
all CCB function calls and enforced by xptioctl() since at
least r168752. Previously we happened to use 0 as the Path
ID, causing the XPT_DEV_MATCH call to fail if there's no
SCSI bus 0. Basically the same bug was also fixed the same
way for camcontrol(8) as part of r126514.

PR:		127605
Submitted by:	Eygene Ryabinkin
Approved by:	silence from ken and scottl
MFC after:	1 week
2008-10-27 21:46:58 +00:00
Matt Jacob
bd3fd815a7 2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.
2006-11-02 00:54:38 +00:00
Joe Marcus Clarke
a7a6dfbd14 Go with a different version of the previous patch so to preserve errno.
Approved by:	scottl (implicit)
2006-04-30 07:08:43 +00:00
Joe Marcus Clarke
8bc181f506 Fix a file descriptor leak in cam_lookup_pass() when the ioctl to find
the passthru device fails.

Approved by:	scottl
MFC after:	1 day
2006-04-30 07:02:40 +00:00
Xin LI
ae73eb3a7f Better memory handling:
- It is acceptable to call free(3) when the given pointer itself
   is NULL, so we do not need to determine NULL before passing
   a pointer to free(3)
 - Handle failure of malloc(3)

MT6/5 Candidate

Submitted by:	Dan Lukes <dan at obluda cz>
PR:		bin/83352
2005-07-13 10:40:07 +00:00
Scott Long
c893420ff0 Change a couple of comments so that GCC doesn't think that they contain
tri-graphs.
2004-07-29 15:35:45 +00:00
Kenneth D. Merry
9460610494 string cleanup:
- fix a potential overrun made worse by rev 1.5 of camlib.h
 - change strncpy() and strcpy() calls to strlcpy()
 - use sizeof(string[]) instead of STRING_LEN to avoid future problems
 - get rid of an unused variable

Thanks to BDE for pointing out some of the problems.

MFC after:	2 weeks
2002-05-14 04:32:02 +00:00
Matthew Dillon
090f02d93c Add __FBSDID()s to libcam 2001-09-30 21:13:43 +00:00
Matt Jacob
3d09a65d42 Make sure you don't have a file descriptor leak for the 'real'
underlying CAM device. This needs to be checked not only in
the open routine, but the device->fd has to be initialized
as well.

PR:		28688
Submitted (partially) by:	T. William Wells <bill@twwells.com>
MFC after:	2 weeks
2001-07-04 07:43:10 +00:00
Matt Jacob
31faeddf80 get pd_type from inquiry data itself 2000-01-16 20:15:43 +00:00
Kenneth D. Merry
661d7edf84 Fix a file descriptor leak in cam_open_btl(). The xpt device was opened,
but never closed.

Submitted by:	amobbs@allstor-sw.co.uk
1999-09-12 19:40:20 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Mike Pritchard
3d416122d3 cam_get_device() was returning 0 on failure, and 1 on success, while
camcontrol(8) and the documentation in camlib.c and cam(3) all expect
-1 on failure and 0 on success.  Updated camlib.c to return the values
specified by the documentation.

PR:	12023
1999-06-15 20:03:01 +00:00
Kenneth D. Merry
b735c71405 Use snprintf to make sure we don't overflow a buffer. 1998-11-15 23:17:39 +00:00
Kenneth D. Merry
2327ec3a76 Fix an error message. (it was using an uninitialized variable)
Reported by:	dan@math.berkeley.edu (Dan Strick)
1998-11-15 23:12:42 +00:00
Kenneth D. Merry
621a60d46b Add a "dummy light" (actually two dummy lights) to catch people who don't
have the passthrough device configured in their kernel.

This will hopefully reduce the number of people complaining that they can't
get {camcontrol, xmcd, tosha, cdrecord, etc.} to work.

Reviewed by:	gibbs
1998-10-12 21:54:13 +00:00
Justin T. Gibbs
f736a45077 CAM userland utility library, a replacement for libscsi.
Submitted by: "Kenneth D. Merry" <ken@FreeBSD.org>
1998-09-15 06:16:46 +00:00