mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-29 16:49:55 +00:00
Feature explicit device type (rascsi) (#177)
* Added support for explicit file type * Check file type * Manpage update * Removed device file work-around, an explicit type can be used instead Co-authored-by: akuker <akuker@gmail.com>
This commit is contained in:
parent
79de9e29e0
commit
1c8c3600a7
@ -54,10 +54,10 @@ The rascsi server port, default is 6868.
|
|||||||
.BR \-v\fI " " \fI
|
.BR \-v\fI " " \fI
|
||||||
Display the rascsi version.
|
Display the rascsi version.
|
||||||
.TP
|
.TP
|
||||||
.BR \-ID\fIn " " \fIFILE
|
.BR \-ID\fIn " " \fIFILE[:TYPE]
|
||||||
n is the SCSI ID number (0-7)
|
n is the SCSI ID number (0-7)
|
||||||
.IP
|
.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
|
.TP
|
||||||
.BR \-HD\fIn " " \fIFILE
|
.BR \-HD\fIn " " \fIFILE
|
||||||
n is the SASI ID number (0-15)
|
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
|
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
|
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:
|
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.hds
|
rascsi -ID0 /dev/hdb:SCSI_HD
|
||||||
|
|
||||||
To create an empty, 100MB HD image, use the following command:
|
To create an empty, 100MB HD image, use the following command:
|
||||||
dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800
|
dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800
|
||||||
|
@ -63,13 +63,15 @@ OPTIONS
|
|||||||
|
|
||||||
-v Display the rascsi version.
|
-v Display the rascsi version.
|
||||||
|
|
||||||
-IDn FILE
|
-IDn FILE[:TYPE]
|
||||||
n is the SCSI ID number (0-7)
|
n is the SCSI ID number (0-7)
|
||||||
|
|
||||||
FILE is the name of the image file to attach to that ID. If FILE
|
FILE is the name of the image file to attach to that ID. If FILE
|
||||||
starts with '/dev/' the extension, which encodes the device
|
starts with '/dev/' the extension, which encodes the device
|
||||||
type, is stripped, so that device files can conveniently be used
|
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
|
-HDn FILE
|
||||||
n is the SASI ID number (0-15)
|
n is the SASI ID number (0-15)
|
||||||
|
@ -552,12 +552,6 @@ bool ProcessCmd(int fd, const PbCommand &command)
|
|||||||
return ReturnStatus(fd, false, error);
|
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
|
// Copy the Unit List
|
||||||
Disk *map[CtrlMax * UnitNum];
|
Disk *map[CtrlMax * UnitNum];
|
||||||
memcpy(map, disk, sizeof(disk));
|
memcpy(map, disk, sizeof(disk));
|
||||||
@ -569,6 +563,28 @@ bool ProcessCmd(int fd, const PbCommand &command)
|
|||||||
return ReturnStatus(fd, false, error);
|
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 no type was specified try to derive the file type from the extension
|
||||||
if (type == UNDEFINED) {
|
if (type == UNDEFINED) {
|
||||||
if (ext == "hdf") {
|
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)
|
// 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");
|
return ReturnStatus(fd, false, "Missing filename");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,9 +641,6 @@ bool ProcessCmd(int fd, const PbCommand &command)
|
|||||||
|
|
||||||
// drive checks files
|
// drive checks files
|
||||||
if (type != BR && type != DAYNAPORT && !command.params().empty()) {
|
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
|
// Set the Path
|
||||||
filepath.SetPath(file.c_str());
|
filepath.SetPath(file.c_str());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user