From owner-freebsd-scsi@FreeBSD.ORG Mon Oct 25 17:29:14 2010 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B25DD1065696 for ; Mon, 25 Oct 2010 17:29:14 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ew0-f54.google.com (mail-ew0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 46D418FC22 for ; Mon, 25 Oct 2010 17:29:13 +0000 (UTC) Received: by ewy28 with SMTP id 28so1704208ewy.13 for ; Mon, 25 Oct 2010 10:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=zRz0vz6QXavLohb3tBiH2UUQRgPQx26pWIcUiHNeDk4=; b=wY7LGl+HBIFj4Fxmzq1Fa2nwPltvWZ/PBS/Bg4AjkY04DxBvXV2A0scyKVDfii3JvM VZOJv8F+QB3KrPDjaKgU82znLZRZQmBzvkhnC+xXDmW0XhPHQth6aNOo/xXDUi5Oo8TZ 0+A/4b7NFHK5+rov9KX5GIaH0VO2WVA2QEPK8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=uFGF1ZacmMEEH2UMxUeRMs9yMizjqu9EWLs8laZl89+kcqichlfkYLL9IhPBExUitM lCfQtQeWVK7s2/zWKSuev6llDvXflS1gq9Y0XDIElXQK3yGFZXiyzz0C8CJRbttf9cCx Qf8ILxxq6iVY4i1n3+FKAlMShcPuuN5YnCPD4= MIME-Version: 1.0 Received: by 10.213.17.199 with SMTP id t7mr5950679eba.90.1288025988783; Mon, 25 Oct 2010 09:59:48 -0700 (PDT) Received: by 10.213.14.71 with HTTP; Mon, 25 Oct 2010 09:59:48 -0700 (PDT) Date: Mon, 25 Oct 2010 12:59:48 -0400 Message-ID: From: Ryan Stone To: freebsd-scsi@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: camcontrol rescan all fails if there is no bus 0 X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2010 17:29:14 -0000 If you issue a "camcontrol rescan all" on a system that does not have scsi bus 0, camcontrol gets a EINVAL from a CAMIOCOMMAND ioctl and exits after printing an error while trying to do a XPT_DEV_MATCH. This is because camcontrol passes a bzero'd ccb to the ioctl without ever setting the path_id, so CAM looks up path 0 and returns EINVAL if that bus does not exist. This is just slightly annoying if there are no CAM devices on the system. If you had a system with CAM devices, but no bus 0, then camcontrol rescan all would always fail. I'm not sure if it's actually possible to skip path 0, though. The following patch resolves the issue for me: Index: camcontrol.c =================================================================== --- camcontrol.c (revision 214271) +++ camcontrol.c (working copy) @@ -1519,6 +1519,7 @@ rescan_or_reset_bus(int bus, int rescan) bzero(&(&matchccb.ccb_h)[1], sizeof(struct ccb_dev_match) - sizeof(struct ccb_hdr)); matchccb.ccb_h.func_code = XPT_DEV_MATCH; + matchccb.ccb_h.path_id = CAM_BUS_WILDCARD; bufsize = sizeof(struct dev_match_result) * 20; matchccb.cdm.match_buf_len = bufsize; matchccb.cdm.matches=(struct dev_match_result *)malloc(bufsize); (by the way, should I be using CAM_BUS_WILDCARD or CAM_XPT_PATH_ID? By the name WILDCARD seems more appropriate but I see that camcontrol uses CAM_XPT_PATH_ID in getdevtree.