Date: 31 Jul 1998 01:12:18 -0400 From: Cory Kempf <ckempf@enigami.com> To: freebsd-scsi@FreeBSD.ORG Subject: dev links won't open. Why? Message-ID: <x71zr2y571.fsf@singularity.enigami.com>
next in thread | raw e-mail | index | archive | help
As root, create a link to a /dev/pass device, e.g.
ln -s /dev/pass3 /dev/scanner
Again as root, attempt to open /dev/scanner via cam_open_device.
It fails. Why? Assuming it is a bug in cam_open_device, can we get
it fixed?
Thanks,
+C
Some sample code to demonstrate the problem (yes, you can try this at
home, kids!):
Extract the program below into a file named st.cc. Then, create the
link as above to one of your pass devices -- doens't have to be a
scanner. Adjust the paths (kDevice and kLink) in the code if
necessary. To compile, use the following:
g++ st.cc -lcam -o st
File st.cc:
##################################################################
#include <iostream.h>
// BUG: camlib left these out.
__BEGIN_DECLS
#include <camlib.h>
__END_DECLS
#include <string.h>
#include <errno.h>
// camlib really should include this:
#include <fcntl.h>
const char* kDevice = "/dev/pass3"; // edit this for your configuration
const char* kLink = "/dev/scanner"; // create this device by doing an
// ln -s <kDevice> /dev/scanner
// alternatively, try linking to
// /dev/rpass#
ostream& operator<<(ostream& o, cam_device* c) {
o << "Device Info: "
<< "\tdevice_path: " << c->device_path << endl
<< "\tgiven_dev_name: " << c->given_dev_name << endl
<< "\tgiven_unit_number: " << c->given_unit_number << endl
<< "\tdevice_name: " << c->device_name << endl
<< "\tdev_unit_num: " << c->dev_unit_num << endl
<< "\tsim_name: " << c->sim_name << endl
<< "\tsim_unit_number: " << c->sim_unit_number << endl
<< "\tbus_id: " << c->bus_id << endl
<< "\ttarget_lun: " << c->target_lun << endl
<< "\ttarget_id: " << c->target_id << endl
<< "\tpd_type: " << c->pd_type << endl
<< "\tinq_data:" << endl
<< "\t\tdevice: " << hex << int(c->inq_data.device) << endl
<< "\t\tdev_qual2: " << hex << int(c->inq_data.dev_qual2) << endl
<< "\t\tversion: " << hex << int(c->inq_data.version) << endl
<< "\t\tresponse_format: " << hex << int(c->inq_data.response_format) << endl
<< "\t\tadditional_length: " << hex << int(c->inq_data.additional_length) << endl
<< "\t\treserved: " << hex << short(c->inq_data.reserved) << endl;
char vendor[SID_VENDOR_SIZE + 1];
strncpy(vendor, c->inq_data.vendor, SID_VENDOR_SIZE);
vendor[SID_VENDOR_SIZE] = '\0';
char product[SID_PRODUCT_SIZE + 1];
strncpy(product, c->inq_data.product, SID_PRODUCT_SIZE);
product[SID_PRODUCT_SIZE] = '\0';
char revision[SID_REVISION_SIZE + 1];
strncpy(revision, c->inq_data.revision, SID_REVISION_SIZE);
revision[SID_REVISION_SIZE] = '\0';
o << "\t\tvendor: " << vendor << endl
<< "\t\tproduct: " << product << endl
<< "\t\trevision: " << revision << endl;
o << "\tserial_num: ";
for(int i = 0; i < ((c->serial_num_len + 1) / 2); i++)
o << hex << ((short*)(c->serial_num))[i] << " ";
o << endl
<< "\tserial_num_len: " << int(c->serial_num_len) << endl
<< "\tsync_period: " << int(c->sync_period) << endl
<< "\tsync_offset: " << int(c->sync_offset) << endl
<< "\tbus_width: " << int(c->bus_width) << endl
<< "\tfd: " << c->fd << endl;
return o;
}
void runtest(const char* path) {
// this line prints out a warning: it is a bug in cam_open_device
cam_device* dev = cam_open_device(path, O_RDWR);
int err = errno;
if(dev != NULL)
cout << "PASSED. " << dev << endl;
else
cout << "**FAILED** errno = " << err << endl;
}
main(void) {
cout << "Testing linked device." << endl
<< "Test one: open device " << kDevice << endl
<< "This test should PASS" << endl << endl;
runtest(kDevice);
cout << "Test two: link to device " << kLink << endl
<< "This test should FAIL" << endl << endl;
runtest(kLink);
cout << "End of Tests" << endl;
}
#################################################################
--
Thinking of purchasing RAM from the Chip Merchant?
Please read this first: <http://www.enigami.com/~ckempf/chipmerchant.html>
Cory Kempf Macintosh / Unix Consulting & Software Development
ckempf@enigami.com <http://www.enigami.com/~ckempf/>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?x71zr2y571.fsf>
