Allow Read Only External Files - Design Specification
See also: Functional Specification
High Level Design
The goal of this change is to allow InterBase to access external files on Read only devices like CD-ROMs, Read only disk partitions etc.
High Level Algorithm
The feature is implemented by also attempting to open the file in a read only mode, if the file is opened in a read only mode a flag is set to indicate that this is a read only file. During insert this flag is checked, if the read only flag is set the client is returned an error instead of an attempt at inserting data being made.
Detailed Design
Internal Data Structures
No new data structures have been added to implement this functionality. Detailed Algorithm
In the function EXT_file() where the external file is opened for access, the following has been added.
EXT_file (relation, file_name, …)
{
…….
…….
file->ext_flags=0;
if (!(file->ext_ifi=(int*) fopen (file_name, FOPEN_TYPE)))
{
/* could not open the file as read write attempt as read only */
if (!(file->ext_ifi=(int*) fopen (file_name, FOPEN_READ_ONLY)))
ERR_post (isc_io_error,
gds_arg_string, "fopen",
gds_arg_string, file->ext_filename,
isc_arg_gds, isc_io_open_err,
SYS_ERR, errno, 0);
else file->ext_flags |=EXT_readonly;
}
……..
……..
}
In the function EXT_store(), where the external file is updated the following check has been added;
void EXT_store (RPB *rpb, int *transaction)
{
……….
/* check if file is read only if read only then
post error we cannot write to this file */
if (file->ext_flags & EXT_readonly)
ERR_post (isc_io_error,
gds_arg_string, "store",
gds_arg_string, file->ext_filename,
isc_arg_gds, isc_io_write_err,
gds_arg_gds, gds__ext_readonly_err, 0);
……….
……….
}
New/Affected Modules
All the changes are in the file ext.c in jrd componnent.
Testing Considerations
The tests should be tried on read only devices like CD-ROM, and write protected floppy drives and also on read only files and read only partitions.