SMREmulator 1.0
ShingledMagneticRecordingEmulator
|
Defines the Macros, data types and functions for using the SMR Emulator. More...
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <emulator.h>
#include <emudebug.h>
#include <emudiskimg.h>
#include <ediversion.h>
#include <emulog.h>
Go to the source code of this file.
Data Structures | |
struct | edi_fd_t |
Structure of the file descriptor lookup table used by the Emulator. More... | |
Defines | |
#define | EDI_MAGIC_NUMBER 0xE5D10000U |
Magic Number identifying the disk image files. | |
Functions | |
int | edi_create (const char *filename, uint32_t version,...) |
Creates a new EDI file based on the parameters specified. | |
int | edi_dump (int fd) |
Dumps the metadata for the specified EDI file. | |
int | edi_open (const char *filename) |
Opens the specified EDI file and verifies its validity. | |
int | edi_close (int fd) |
Closes an open EDI file. | |
int | edi_modesense (int fd, inq_t inq, void *data) |
Queries the Emulated Disk to retrieve disk parameters such as block size, band count, etc. | |
int | edi_managebands (int fd, svc_act_t action, band_t *band, rba_t *rba, int len) |
Manages bands on the Emulated Disk. | |
int | edi_read (int fd, band_t band, rba_t rba, char *buf, rba_t len) |
Reads data from the specified band and block. | |
int | edi_write (int fd, band_t band, rba_t rba, char *buf, rba_t len) |
Writes data to the specified band and block. | |
int | edi_init () |
Defines the Macros, data types and functions for using the SMR Emulator.
Definition in file emudiskimg.c.
int edi_close | ( | int | fd | ) |
Closes an open EDI file.
fd | The file descriptor index returned by edi_open() |
Error Codes:
Other than the above, the function also returns the error codes returned by close() and the close() function call for the specific EDI version.
Definition at line 285 of file emudiskimg.c.
int edi_create | ( | const char * | filename, |
uint32_t | version, | ||
... | |||
) |
Creates a new EDI file based on the parameters specified.
filename | The name of the new EDI file |
version | The EDI format version to use for creating the new EDI file |
... | Version specific parameters |
Error Codes:
Other than the above, the function also returns the error codes returned by open(), pwrite() and the create() function for the specific EDI version.
Definition at line 82 of file emudiskimg.c.
References EDI_MAGIC_NUMBER, and ediv_is_valid().
int edi_dump | ( | int | fd | ) |
Dumps the metadata for the specified EDI file.
Calling this function sends output to stdout. All metadata for the specified EDI file is printed, including the version, block size, band count, and the write pointers for each band.
fd | The file descriptor index returned by edi_open() |
Error Codes:
Definition at line 164 of file emudiskimg.c.
int edi_init | ( | ) |
Initializes the Emulated Disk Image interface.
Definition at line 569 of file emudiskimg.c.
References ediv_init(), emulog_open(), and MAX_EDIS.
Manages bands on the Emulated Disk.
The Manage Bands command is used for multiple actions, depending on the Service Action requested. Each Service Action expects a certain number of parameters for the function to execute correctly.
1. SVC_GETPTR: Retrieves the Write Pointer for the specified band. It expects 2 parameters:
2. SVC_SETPTR: Sets the Write Pointer for the specified band. It expects 2 parameters:
3. SVC_GETMULTIPLE: Retrieves the Write Pointers for multiple bands. It expects 3 parameters:
4. SVC_RESETALL: Resets the Write Pointers of all bands to the start of the band. This function does not expect any parameters.
5. SVC_GETBANDCONFIG: Retrieves the band configuration for the specific band. It expects 2 parameters:
fd | The file descriptor index returned by edi_open() |
action | The desired action to perform |
band | Pointer to the band on which the action is to be performed |
rba | Pointer to the RBA for the operation |
len | Length of the array of band numbers (only for SVC_GETMULTIPLE) |
Error Codes:
Other than the above, the function also returns the error codes returned by the managegbands() function call for the specific EDI version.
Definition at line 417 of file emudiskimg.c.
int edi_modesense | ( | int | fd, |
inq_t | inq, | ||
void * | data | ||
) |
Queries the Emulated Disk to retrieve disk parameters such as block size, band count, etc.
This function takes a void pointer for the data variable. However, internally, it will cast the pointer to the desired type depending on the data being requested. It is up to the programmer to ensure that the pointer being passed addresses the required amount of memory for the returned data.
fd | The file descriptor index returned by edi_open() |
inq | The Inquiry code for the desired data |
data | Pointer to a variable to store the returned data |
Error Codes:
Definition at line 334 of file emudiskimg.c.
int edi_open | ( | const char * | filename | ) |
Opens the specified EDI file and verifies its validity.
In case or any errors, the function DOES NOT close the open EDI file. It is up to the programmer to detect any errors, handle them accordingly and then close the open EDI file.
filename | Path to the EDI file. |
Errors returned:
Other than the above, the function also returns the error codes returned by open() and the open() function for the specific EDI version.
Definition at line 205 of file emudiskimg.c.
References EDI_MAGIC_NUMBER, and ediv_is_valid().
Reads data from the specified band and block.
It is up to the programmer to ensure that the buffer passed to the function is sufficiently large to hold the requested data.
fd | The file descriptor index returned by edi_open() |
band | The Band no. of the band from which data is to be read |
rba | The starting block in the band from which data is to be read |
buf | Pointer to the buffer into which the data is to be read |
len | Number of contiguous "blocks" to read, starting from rba |
Error Codes:
Definition at line 493 of file emudiskimg.c.
Writes data to the specified band and block.
fd | The file descriptor index returned by edi_open() |
band | The Band no. of the band to which data is to be written |
rba | The starting block in the band to which data is to be written |
buf | Pointer to the buffer which holds the data is to be written |
len | Number of contiguous "blocks" to write, starting from rba |
Error Codes:
Definition at line 536 of file emudiskimg.c.