diff --git a/doc/rascsi.1 b/doc/rascsi.1 index da72b97f..bca94ebb 100644 --- a/doc/rascsi.1 +++ b/doc/rascsi.1 @@ -3,19 +3,24 @@ rascsi \- Emulates SCSI devices using the Raspberry Pi GPIO pins .SH SYNOPSIS .B rascsi -[\fB\-IDn\fR \fIfile\fR] -[\fB\-HDn\fR \fIfile\fR]... +[\fB\-f\f® \fIFOLDER\fR] +[\fB\-g\f® \fILOG_LEVEL\fR] +[\fB\-h\fR] +[\fB\-p\f® \fIPORT\fR] +[\fB\-v\fR] +[\fB\-IDn\fR \fIFILE\fR] +[\fB\-HDn\fR \fIFILE\fR]... .SH DESCRIPTION .B rascsi Emulates SCSI devices using the Raspberry Pi GPIO pins. .PP In the arguments to RaSCSI, one or more SCSI (-IDn) or SASI (-HDn) devices can be specified. The number (n) after the ID or HD identifier specifies the ID number for that device. -For SCSI: The ID is limited from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" (the host computer).Note that SASI is considered rare and only used on very early Sharp X68000 computers. +For SCSI: The ID is limited from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" (the host computer). Note that SASI is considered rare and only used on very early Sharp X68000 computers. .PP RaSCSI will determine the type of device based upon the file extension of the FILE argument. hdf: SASI Hard Disk image (XM6 SASI HD image - typically only used with X68000) - hds: SCSI Hard Disk image (XM6 SCSI HD image - typically only used with X68000) + hds: SCSI Hard Disk image (generic) hdn: SCSI Hard Disk image (NEC GENUINE) hdi: SCSI Hard Disk image (Anex86 HD image) nhd: SCSI Hard Disk image (T98Next HD image) @@ -26,23 +31,38 @@ RaSCSI will determine the type of device based upon the file extension of the FI For example, if you want to specify an Apple-compatible HD image on ID 0, you can use the following command: sudo rascsi -ID0 /path/to/drive/hdimage.hda -Once RaSCSI starts, it will open a socket (port 6868) to allow external management commands. -If another process is using port 6868, RaSCSI will terminate, since it is likely another instance of RaSCSI. +Once RaSCSI starts, it will open a socket (default port is 6868) to allow external management commands. +If another process is using the rascsi port, RaSCSI will terminate, since it is likely another instance of RaSCSI. Once RaSCSI has initialized, the rasctl utility can be used to send commands. To quit RaSCSI, press Control + C. If it is running in the background, you can kill it using an INT signal. .SH OPTIONS .TP +.BR \-f\fI " " \fIFOLDER +The default folder for image files. For files in this folder no absolute path needs to be specified. The default folder is '/home/pi/images'. +.TP +.BR \-g\fI " " \fILOG_LEVEL +The rascsi log level (trace, debug, info, warn, err, critical, off). The default log level is 'trace'. +.TP +.BR \-h\fI " " \fI +Show a help page. +.TP +.BR \-p\fI " " \fIPORT +The rascsi server port, default is 6868. +.TP +.BR \-v\fI " " \fI +Display the rascsi version. +.TP .BR \-ID\fIn " " \fIFILE n is the SCSI ID number (0-7) .IP -FILE is the name of the image file to attach to that ID. +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. .TP .BR \-HD\fIn " " \fIFILE n is the SASI ID number (0-15) .IP -FILE is the name of the image file to attach to that ID. +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. .IP Note: SASI usage is rare, and is typically limited to early Sharp X68000 systems. @@ -50,12 +70,18 @@ Note: SASI usage is rare, and is typically limited to early Sharp X68000 systems Launch RaSCSI with no emulated drives attached: rascsi -Launch RaSCSI with an Apple hard drive image as ID0 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 +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 + To create an empty, 100MB HD image, use the following command: dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800 +In case the fallocate command is available a much faster alternative to the dd command is: + fallocate -l 104857600 /path/to/newimage.hda + .SH SEE ALSO rasctl(1), scsimon(1) diff --git a/doc/rascsi_man_page.txt b/doc/rascsi_man_page.txt index a98d6836..26fe4de6 100644 --- a/doc/rascsi_man_page.txt +++ b/doc/rascsi_man_page.txt @@ -1,31 +1,29 @@ !! ------ THIS FILE IS AUTO_GENERATED! DO NOT MANUALLY UPDATE!!! -!! ------ The native file is rascsi.1. Re-run 'make docs' after updating - - +!! ------ The native file is rascsi.1. Re-run 'make docs' after updating\n\n rascsi(1) General Commands Manual rascsi(1) NAME rascsi - Emulates SCSI devices using the Raspberry Pi GPIO pins SYNOPSIS - rascsi [-IDn file] [-HDn file]... + rascsi [-f[u00AE] FOLDER] [-g[u00AE] LOG_LEVEL] [-h] [-p[u00AE] PORT] + [-v] [-IDn FILE] [-HDn FILE]... DESCRIPTION rascsi Emulates SCSI devices using the Raspberry Pi GPIO pins. - In the arguments to RaSCSI, one or more SCSI (-IDn) or SASI (-HDn) de‐ - vices can be specified. The number (n) after the ID or HD identifier - specifies the ID number for that device. For SCSI: The ID is limited - from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" - (the host computer).Note that SASI is considered rare and only used on + In the arguments to RaSCSI, one or more SCSI (-IDn) or SASI (-HDn) de‐ + vices can be specified. The number (n) after the ID or HD identifier + specifies the ID number for that device. For SCSI: The ID is limited + from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" + (the host computer). Note that SASI is considered rare and only used on very early Sharp X68000 computers. - RaSCSI will determine the type of device based upon the file extension + RaSCSI will determine the type of device based upon the file extension of the FILE argument. - hdf: SASI Hard Disk image (XM6 SASI HD image - typically only used - with X68000) - hds: SCSI Hard Disk image (XM6 SCSI HD image - typically only used + hdf: SASI Hard Disk image (XM6 SASI HD image - typically only used with X68000) + hds: SCSI Hard Disk image (generic) hdn: SCSI Hard Disk image (NEC GENUINE) hdi: SCSI Hard Disk image (Anex86 HD image) nhd: SCSI Hard Disk image (T98Next HD image) @@ -39,40 +37,70 @@ DESCRIPTION 0, you can use the following command: sudo rascsi -ID0 /path/to/drive/hdimage.hda - Once RaSCSI starts, it will open a socket (port 6868) to allow external - management commands. If another process is using port 6868, RaSCSI - will terminate, since it is likely another instance of RaSCSI. Once - RaSCSI has initialized, the rasctl utility can be used to send com‐ - mands. + Once RaSCSI starts, it will open a socket (default port is 6868) to al‐ + low external management commands. If another process is using the + rascsi port, RaSCSI will terminate, since it is likely another instance + of RaSCSI. Once RaSCSI has initialized, the rasctl utility can be used + to send commands. To quit RaSCSI, press Control + C. If it is running in the background, you can kill it using an INT signal. OPTIONS + -f FOLDER + The default folder for image files. For files in this folder no + absolute path needs to be specified. The default folder is + '/home/pi/images'. + + -g LOG_LEVEL + The rascsi log level (trace, debug, info, warn, err, critical, + off). The default log level is 'trace'. + + -h Show a help page. + + -p PORT + The rascsi server port, default is 6868. + + -v Display the rascsi version. + -IDn FILE n is the SCSI ID number (0-7) - FILE is the name of the image file to attach to that ID. + 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. -HDn FILE n is the SASI ID number (0-15) - FILE is the name of the image file to attach to that ID. + 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. - Note: SASI usage is rare, and is typically limited to early + Note: SASI usage is rare, and is typically limited to early Sharp X68000 systems. EXAMPLES Launch RaSCSI with no emulated drives attached: rascsi - Launch RaSCSI with an Apple hard drive image as ID0 and a CD-ROM as ID + 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 + To create an empty, 100MB HD image, use the following command: dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800 + In case the fallocate command is available a much faster alternative to + the dd command is: + fallocate -l 104857600 /path/to/newimage.hda + SEE ALSO rasctl(1), scsimon(1) diff --git a/doc/rasctl.1 b/doc/rasctl.1 index b542d7f8..6e9c695b 100644 --- a/doc/rasctl.1 +++ b/doc/rasctl.1 @@ -4,11 +4,16 @@ rasctl \- Sends management commands to the rascsi process .SH SYNOPSIS .B rasctl \fB\-l\fR | +\fB\-s\fR | +[\fB\-g\fR \fILOG_LEVEL\fR] +[\fB\-h\fR \fIHOST\fR] +[\fB\-p\fR \fIPORT\fR] +[\fB\-v\fR] \fB\-i\fR \fIID\fR -[\fB\-u\fR \fIUNIT\fR] [\fB\-c\fR \fICMD\fR] -[\fB\-t\fR \fITYPE\fR] [\fB\-f\fR \fIFILE\fR] +[\fB\-t\fR \fITYPE\fR] +[\fB\-u\fR \fIUNIT\fR] .SH DESCRIPTION .B rasctl Sends commands to the rascsi process to make configuration adjustments at runtime or to check the status of the devices. @@ -21,15 +26,27 @@ Note: The command and type arguments are case insensitive. Only the first letter .SH OPTIONS .TP +.BR \-g\fI " "\fILOG_LEVEL +The rascsi log level to set (trace, debug, info, warn, err, critical, off) +.TP +.BR \-h\fI " " \fIHOST +The rascsi host to connect to, default is 'localhost'. +.TP .BR \-l\fI List all of the devices that are currently being emulated by RaSCSI, as well as their current status. .TP +.BR \-p\fI " " \fIPORT +The rascsi port to connect to, default is 6868. +.TP +.BR \-s\fI +Display the server-side configuration settings. +.TP +.BR \-v\fI " " \fI +Display the rascsi version. +.TP .BR \-i\fI " " \fIID ID is the SCSI ID that you want to control. (0-7) .TP -.BR \-u\fI " " \fIUNIT -Unit number (0 or 1). This will default to 0. This option is only used when there are multiple SCSI devices on a shared SCSI controller. (This is not common) -.TP .BR \-c\fI " " \fICMD Command is the operation being requested. options are: attach: attach disk @@ -40,6 +57,9 @@ Command is the operation being requested. options are: .IP When the command is omitted, rasctl will default to the 'attach' command. .TP +.BR \-f\fI " " \fIFILE +Path to the disk image file. See the rascsi(1) man page for allowable file types. +.TP .BR \-t\fI " " \fITYPE Specifies the type of disk. If this disagrees with the file extension of the specified image, the TYPE argument is ignored. Available drive types are: hd: Hard disk (SCSI or SASI) @@ -47,8 +67,8 @@ Specifies the type of disk. If this disagrees with the file extension of the spe cd: CD-ROM bridge: Bridge device (This is only applicable to the Sharp X68000) .TP -.BR \-f\fI " " \fIFILE -Path to the disk image file. See the rascsi(1) man page for allowable file types. +.BR \-u\fI " " \fIUNIT +Unit number (0 or 1). This will default to 0. This option is only used when there are multiple SCSI devices on a shared SCSI controller. (This is not common) .SH EXAMPLES Show a listing of all of the SCSI devices and their current status. diff --git a/doc/rasctl_man_page.txt b/doc/rasctl_man_page.txt index a460a1dc..35ebe34b 100644 --- a/doc/rasctl_man_page.txt +++ b/doc/rasctl_man_page.txt @@ -1,36 +1,42 @@ !! ------ THIS FILE IS AUTO_GENERATED! DO NOT MANUALLY UPDATE!!! -!! ------ The native file is rasctl.1. Re-run 'make docs' after updating - - +!! ------ The native file is rasctl.1. Re-run 'make docs' after updating\n\n rascsi(1) General Commands Manual rascsi(1) NAME rasctl - Sends management commands to the rascsi process SYNOPSIS - rasctl -l | -i ID [-u UNIT] [-c CMD] [-t TYPE] [-f FILE] + rasctl -l | -s | [-g LOG_LEVEL] [-h HOST] [-p PORT] -i ID [-c CMD] [-f + FILE] [-t TYPE] [-u UNIT] DESCRIPTION - rasctl Sends commands to the rascsi process to make configuration ad‐ + rasctl Sends commands to the rascsi process to make configuration ad‐ justments at runtime or to check the status of the devices. Either the -i or -l option should be specified at one time. Not both. You do NOT need root privileges to use rasctl. - Note: The command and type arguments are case insensitive. Only the + Note: The command and type arguments are case insensitive. Only the first letter of the command/type is evaluated by the tool. OPTIONS + -g LOG_LEVEL + The rascsi log level to set (trace, debug, info, warn, err, + critical, off) + + -h HOST + The rascsi host to connect to, default is 'localhost'. + -l List all of the devices that are currently being emulated by RaSCSI, as well as their current status. - -i ID ID is the SCSI ID that you want to control. (0-7) + -p PORT + The rascsi port to connect to, default is 6868. - -u UNIT - Unit number (0 or 1). This will default to 0. This option is - only used when there are multiple SCSI devices on a shared SCSI - controller. (This is not common) + -s Display server-side configuration settings. + + -i ID ID is the SCSI ID that you want to control. (0-7) -c CMD Command is the operation being requested. options are: attach: attach disk @@ -42,19 +48,24 @@ OPTIONS When the command is omitted, rasctl will default to the 'attach' command. + -f FILE + Path to the disk image file. See the rascsi(1) man page for al‐ + lowable file types. + -t TYPE - Specifies the type of disk. If this disagrees with the file ex‐ - tension of the specified image, the TYPE argument is ignored. + Specifies the type of disk. If this disagrees with the file ex‐ + tension of the specified image, the TYPE argument is ignored. Available drive types are: hd: Hard disk (SCSI or SASI) mo: Magneto-Optical disk) cd: CD-ROM - bridge: Bridge device (This is only applicable to the Sharp + bridge: Bridge device (This is only applicable to the Sharp X68000) - -f FILE - Path to the disk image file. See the rascsi(1) man page for al‐ - lowable file types. + -u UNIT + Unit number (0 or 1). This will default to 0. This option is + only used when there are multiple SCSI devices on a shared SCSI + controller. (This is not common) EXAMPLES Show a listing of all of the SCSI devices and their current status. diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index ac5d8a30..da121ddd 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -588,13 +588,6 @@ bool ProcessCmd(int fd, const PbCommand &command) // 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); - if (files_in_use.find(file) != files_in_use.end()) { - ostringstream error; - error << "Image file '" << file << "' is already in use"; - return ReturnStatus(fd, false, error.str()); - } - files_in_use.insert(file); - // Set the Path filepath.SetPath(file.c_str()); @@ -613,6 +606,14 @@ bool ProcessCmd(int fd, const PbCommand &command) return ReturnStatus(fd, false, error.str()); } } + + if (files_in_use.find(filepath.GetPath()) != files_in_use.end()) { + ostringstream error; + error << "Image file '" << file << "' is already in use"; + return ReturnStatus(fd, false, error.str()); + } + + files_in_use.insert(filepath.GetPath()); } // Set the cache to write-through @@ -652,14 +653,12 @@ bool ProcessCmd(int fd, const PbCommand &command) // Free the existing unit map[id * UnitNum + un] = NULL; + Filepath filepath; + pUnit->GetPath(filepath); + files_in_use.erase(filepath.GetPath()); + // Re-map the controller bool status = MapController(map); - if (status) { - Filepath filepath; - pUnit->GetPath(filepath); - - files_in_use.erase(filepath.GetPath()); - } return ReturnStatus(fd, status, status ? "" : "Error : SASI and SCSI can't be mixed\n"); } @@ -728,7 +727,7 @@ bool ParseArgument(int argc, char* argv[], int& port) string log_level = "trace"; int opt; - while ((opt = getopt(argc, argv, "-IiHhG:g:D:d:p:f:")) != -1) { + while ((opt = getopt(argc, argv, "-IiHhG:g:D:d:P:p:f:Vv")) != -1) { switch (tolower(opt)) { case 'i': is_sasi = false; @@ -775,6 +774,11 @@ bool ParseArgument(int argc, char* argv[], int& port) default_image_folder = optarg; continue; + case 'v': + cout << rascsi_get_version_string() << endl; + exit(0); + break; + default: return false; diff --git a/src/raspberrypi/rasctl.cpp b/src/raspberrypi/rasctl.cpp index a2a0d25e..27ef4c08 100644 --- a/src/raspberrypi/rasctl.cpp +++ b/src/raspberrypi/rasctl.cpp @@ -223,13 +223,13 @@ int main(int argc, char* argv[]) if (argc < 2) { cerr << "SCSI Target Emulator RaSCSI Controller" << endl; cerr << "version " << rascsi_get_version_string() << " (" << __DATE__ << ", " << __TIME__ << ")" << endl; - cerr << "Usage: " << argv[0] << " -i ID [-u UNIT] [-c CMD] [-t TYPE] [-f FILE] [-h HOSTNAME] [-p PORT] [-g LOG_LEVEL] [-s]" << endl; + cerr << "Usage: " << argv[0] << " -i ID [-u UNIT] [-c CMD] [-t TYPE] [-f FILE] [-g LOG_LEVEL] [-h HOST] [-p PORT] [-v]" << endl; cerr << " where ID := {0|1|2|3|4|5|6|7}" << endl; cerr << " UNIT := {0|1} default setting is 0." << endl; cerr << " CMD := {attach|detach|insert|eject|protect}" << endl; cerr << " TYPE := {hd|mo|cd|bridge|daynaport}" << endl; cerr << " FILE := image file path" << endl; - cerr << " HOSTNAME := rascsi host to connect to, default is 'localhost'" << endl; + cerr << " HOST := rascsi host to connect to, default is 'localhost'" << endl; cerr << " PORT := rascsi port to connect to, default is 6868" << endl; cerr << " LOG_LEVEL := log level {trace|debug|info|warn|err|critical|off}, default is 'trace'" << endl; cerr << " If CMD is 'attach' or 'insert' the FILE parameter is required." << endl; @@ -249,7 +249,7 @@ int main(int argc, char* argv[]) int port = 6868; string params; opterr = 0; - while ((opt = getopt(argc, argv, "i:u:c:t:f:h:p:g:ls")) != -1) { + while ((opt = getopt(argc, argv, "i:u:c:t:f:h:p:g:lsv")) != -1) { switch (opt) { case 'i': id = optarg[0] - '0'; @@ -343,6 +343,11 @@ int main(int argc, char* argv[]) case 's': cmd = SERVER_INFO; break; + + case 'v': + cout << rascsi_get_version_string() << endl; + exit(0); + break; } }