Previously, Vilas kumar Chitrakaran wrote in comp.os.qnx:
I have two QNX 4.25 license floppies (OS/ Watcom C++) for which I need a
backup copy. I know both floppies work fine. But I am unable to mount the
floppy in order to read it. I get an error message saying ‘corrupted file
system detected’. Any pointers on how to make backup of those license
floppies are appreciated.
Compile the following program and run it. It will convert the licenses to normal files
that can then be cp’d and backed up.
#ifdef __USAGE
This utility allow you to backup your system with license
#endif
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <process.h>
#include <fcntl.h>
#include <dirent.h>
#include <time.h>
#include <errno.h>
main()
{
DIR *dp;
struct dirent *dirp;
int fd;
FILE *fp;
char buf[512], fn[64];
if ( geteuid() != 0 )
exit(-1);
umask( 077 );
dp = opendir("/etc/licenses");
if( !dp ) exit(0);
while(dirp = readdir(dp))
{
if(dirp->d_name[0] == ‘.’)
continue;
memset( buf, 0, sizeof(buf) );
sprintf( fn, “/etc/licenses/%s”, dirp->d_name );
fd = open( fn, O_RDONLY );
if( fd != -1 )
{
if( block_read(fd, 1L, 1, buf) == -1 &&
(errno == ENOSYS || errno == EOPNOTSUPP))
read(fd, buf, 512);
close(fd);
strcat( fn, “X” ); fp = fopen( fn, “w” );
if ( fp )
{
fwrite( buf, 1, 512, fp );
fclose( fp );
strcpy( buf, fn );
fn[ strlen(fn)-1 ] = ‘\0’;
unlink( fn );
rename( buf, fn );
}
}
}
}
Cheers,
Camz.
\
Martin Zimmerman camz@passageway.com
Camz Software Enterprises www.passageway.com/camz/qnx/
QNX Programming & Consulting