int low_write (unsigned char *buffer,unsigned long length,unsigned long offset) /* This is used to change something in the filesystem. write_access is checked to see if we are allowed to do the actual writing. As a double safety measure, AllowChanges is rechecked here. If logging is enabled, we log the change before writing it to the device. */ { char temp [80]; if (!write_access) { wprintw (command_win,"Error - Write access not available (use enablewrite)\n"); return (0); } #ifdef DEBUG if (!AllowChanges) { internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write"); return (0); } if (device_handle==NULL) { internal_error ("No device opened yet read requested","disk","low_write"); return (0); } if (offset > file_system_info.file_system_size) { sprintf (temp,"Seek offset %ld is out of range",offset); internal_error (temp,"disk","low_write"); return (0); } #endif if (LogChanges) if (!log_changes (buffer,length,offset)) return (0); if ( (fseek (device_handle,offset,SEEK_SET))==-1) { wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name); refresh_command_win ();return (0); }; if ( (fwrite (buffer,1,length,device_handle))==-1) { wprintw (command_win,"Error - Failed to write to offset %ld in device %s\n",offset,device_name); refresh_command_win ();return (0); }; wprintw (command_win,"Data written");refresh_command_win (); return (1); }
int low_write (unsigned char *buffer,unsigned long length,unsigned long offset) { char temp [80]; if (!write_access) { wprintw (command_win,"Error - Write access not aviable (use enablewrite)\n"); return (0); } #ifdef DEBUG if (!AllowChanges) { internal_error ("AllowChanges=0 yet enablewrite succeeded","disk","low_write"); return (0); } if (device_handle==NULL) { internal_error ("No device opened yet read requested","disk","low_write"); return (0); } if (offset > file_system_info.file_system_size) { sprintf (temp,"Seek offset %ld is out of range",offset); internal_error (temp,"disk","low_write"); return (0); } #endif if (LogChanges) if (!log_changes (buffer,length,offset)) return (0); if ( (fseek (device_handle,offset,SEEK_SET))==-1) { wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",offset,device_name); refresh_command_win ();return (0); }; if ( (fwrite (buffer,1,length,device_handle))==-1) { wprintw (command_win,"Error - Failed to write to offset %ld in device %s\n",offset,device_name); refresh_command_win ();return (0); }; wprintw (command_win,"Data written");refresh_command_win (); return (1); }