diff --git a/doc/rascsi.1 b/doc/rascsi.1 index bca94ebb..5f0ac645 100644 --- a/doc/rascsi.1 +++ b/doc/rascsi.1 @@ -54,10 +54,10 @@ The rascsi server port, default is 6868. .BR \-v\fI " " \fI Display the rascsi version. .TP -.BR \-ID\fIn " " \fIFILE +.BR \-ID\fIn " " \fIFILE[:TYPE] n is the SCSI ID number (0-7) .IP -FILE is the name of the image file to attach to that ID. If FILE starts with '/dev/' the extension, which encodes the device type, is stripped, so that device files can conveniently be used as image files. +FILE is the name of the image file to attach to that ID. An optional explicit device type (SASI_HD, SCSI_HD, CD, MO, BR, NUVOLINK, DAYNAPORT) can be provided after a colon. .TP .BR \-HD\fIn " " \fIFILE n is the SASI ID number (0-15) @@ -73,8 +73,8 @@ Launch RaSCSI with no emulated drives attached: Launch RaSCSI with an Apple hard drive image as ID 0 and a CD-ROM as ID 2 rascsi -ID0 /path/to/harddrive.hda -ID2 /path/to/cdimage.iso -Launch RaSCSI with a SCSI hard drive image as ID 0 and the raw device file /dev/hdb (e.g. a USB stick) as an image file: - rascsi -ID0 /dev/hdb.hds +Launch RaSCSI with a SCSI hard drive image as ID 0 and the raw device file /dev/hdb (e.g. a USB stick) as a SCSI hard disk image file: + rascsi -ID0 /dev/hdb:SCSI_HD To create an empty, 100MB HD image, use the following command: dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800 diff --git a/doc/rascsi_man_page.txt b/doc/rascsi_man_page.txt index 26fe4de6..722ab5e6 100644 --- a/doc/rascsi_man_page.txt +++ b/doc/rascsi_man_page.txt @@ -63,13 +63,15 @@ OPTIONS -v Display the rascsi version. - -IDn FILE + -IDn FILE[:TYPE] n is the SCSI ID number (0-7) FILE is the name of the image file to attach to that ID. If FILE starts with '/dev/' the extension, which encodes the device type, is stripped, so that device files can conveniently be used - as image files. + as image files. An optional explicit device type (SASI_HD, + SCSI_HD, CD, MO, BR, NUVOLINK, DAYNAPORT) can be provided after + a colon. -HDn FILE n is the SASI ID number (0-15) diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index 817c5073..fc713aae 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -552,12 +552,6 @@ bool ProcessCmd(int fd, const PbCommand &command) return ReturnStatus(fd, false, error); } - string ext; - int len = params.length(); - if (len > 4 && params[len - 4] == '.') { - ext = params.substr(len - 3); - } - // Copy the Unit List Disk *map[CtrlMax * UnitNum]; memcpy(map, disk, sizeof(disk)); @@ -569,6 +563,28 @@ bool ProcessCmd(int fd, const PbCommand &command) return ReturnStatus(fd, false, error); } + string file = params; + + // Try to extract the file type from the filename. Convention: "filename:type". + size_t separatorPos = file.find(':'); + if (separatorPos != string::npos) { + string t = file.substr(separatorPos + 1); + transform(t.begin(), t.end(), t.begin(), ::toupper); + + if (!PbDeviceType_Parse(t, &type)) { + error << "Invalid device type " << t; + return ReturnStatus(fd, false, error); + } + + file = file.substr(0, separatorPos); + } + + string ext; + int len = file.size(); + if (len > 4 && file[len - 4] == '.') { + ext = file.substr(len - 3); + } + // If no type was specified try to derive the file type from the extension if (type == UNDEFINED) { if (ext == "hdf") { @@ -584,7 +600,7 @@ bool ProcessCmd(int fd, const PbCommand &command) } // File check (type is HD, for CD and MO the medium (=file) may be inserted later) - if ((type == SASI_HD || type == SCSI_HD) && params.empty()) { + if ((type == SASI_HD || type == SCSI_HD) && file.empty()) { return ReturnStatus(fd, false, "Missing filename"); } @@ -625,9 +641,6 @@ bool ProcessCmd(int fd, const PbCommand &command) // drive checks files if (type != BR && type != DAYNAPORT && !command.params().empty()) { - // Strip the image file extension from device file names, so that device files can be used as drive images - string file = params.find("/dev/") ? params : params.substr(0, params.length() - 4); - // Set the Path filepath.SetPath(file.c_str());