Exemplo n.º 1
0
/*
 * Copy one raw disk to a file.
 */
int readdevice(char *name, char *dst)
{   /* erhm, I must admit this code is long and ugly! */
    FILE *f = NULL;
    char *device_name;
    int   device_unit;
    int   retstatus = 0;
#ifdef HAVE_SIGACTION
    struct sigaction sa, oldsa;
    int oldsa_valid;

    /* disable break */
    sa.sa_handler = SIG_IGN;
    sa.sa_flags = 0;
    sigemptymask(&sa.sa_mask);
    oldsa_valid = (0==sigaction(SIGINT, &sa, &oldsa));
#endif

    /* get device name & unit */
    extract_dev_unit(name, &device_name, &device_unit);
    if(device_name) {
	/* if no destination then just check if the device exists */
	if(dst == NULL)
	   retstatus = device_exists(device_name, device_unit);
	else {
	    /* open dest file */
	    if((f = fopen(dst,"wb"))) {
		retstatus = raw_copy(device_name, device_unit, f);
		fclose(f);
	    }
	}
	free(device_name);
    }

#ifdef HAVE_SIGACTION
    /* enable break */
    if(oldsa_valid) sigaction(SIGINT, &oldsa, NULL);
#endif

    return retstatus;
}
Exemplo n.º 2
0
/*
 * Copy one raw disk to a file.
 */
int readdevice(char *name, char *dst)
{   /* erhm, I must admit this code is long and ugly! */
    FILE *f = NULL;
    char *device_name;
    int   device_unit;
    int   retstatus = 0;
#ifdef HAVE_SIGACTION
    struct sigaction oldsa;
    int oldsa_valid;

    /* disable break */
    oldsa_valid = (0==sigaction(SIGINT, NULL, &oldsa));
    signal(SIGINT, SIG_IGN); /* <--- gcc complains about something */
			     /* in there but I don't know why. */
#endif

    /* get device name & unit */
    extract_dev_unit(name, &device_name, &device_unit);
    if(device_name) {
	/* if no destination then just check if the device exists */
	if(dst == NULL)
	   retstatus = device_exists(device_name, device_unit);
	else {
	    /* open dest file */
	    if((f = fopen(dst,"wb"))) {
		retstatus = raw_copy(device_name, device_unit, f);
		fclose(f);
	    }
	}
	free(device_name);
    }

#ifdef HAVE_SIGACTION
    /* enable break */
    if(oldsa_valid) sigaction(SIGINT, &oldsa, NULL);
#endif

    return retstatus;
}