/*
- * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+ * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
PROPERTY_ACCESS_GET_MASK | PROPERTY_ACCESS_SET_BEFORE_START,
tape_device_get_read_block_size_fn,
tape_device_set_read_block_size_fn);
+
+ /* add the ability to set LEOM to FALSE, for testing purposes */
+ device_class_register_property(device_class, PROPERTY_LEOM,
+ PROPERTY_ACCESS_GET_MASK | PROPERTY_ACCESS_SET_BEFORE_START,
+ device_simple_property_get_fn,
+ tape_device_set_feature_property_fn);
}
static gboolean
self->bsf_after_eom = new_bool;
else if (base->ID == PROPERTY_NONBLOCKING_OPEN)
self->nonblocking_open = new_bool;
+ else if (base->ID == PROPERTY_LEOM)
+ self->leom = new_bool;
else
return FALSE; /* shouldn't happen */
/* looks good .. let's start the device over, though */
device_clear_volume_details(p_self);
} else {
+ device_set_error(p_self,
+ g_strdup("Error setting COMPRESION property"),
+ DEVICE_STATUS_DEVICE_ERROR);
return FALSE;
}
if (read_block_size != 0 &&
((gsize)read_block_size < p_self->block_size ||
(gsize)read_block_size > p_self->max_block_size))
+ device_set_error(p_self,
+ g_strdup_printf("Error setting READ-BLOCk-SIZE property to '%u', it must be between %zu and %zu", read_block_size, p_self->block_size, p_self->max_block_size),
+ DEVICE_STATUS_DEVICE_ERROR);
return FALSE;
self->private->read_block_size = read_block_size;
return dself->status;
}
+ dself->header_block_size = buffer_len;
header = dself->volume_header = g_new(dumpfile_t, 1);
fh_init(header);
}
pself->block++;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_written += size;
+ g_mutex_unlock(pself->device_mutex);
return TRUE;
}
case RESULT_SUCCESS:
*size_req = size;
pself->block++;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_read += size;
+ g_mutex_unlock(pself->device_mutex);
return size;
case RESULT_SMALL_BUFFER: {
gsize new_size;
}
case RESULT_NO_DATA:
pself->is_eof = TRUE;
+ g_mutex_lock(pself->device_mutex);
pself->in_file = FALSE;
+ g_mutex_unlock(pself->device_mutex);
device_set_error(pself,
stralloc(_("EOF")),
DEVICE_STATUS_SUCCESS);
return FALSE;
}
+ d_self->header_block_size = d_self->block_size;
amfree(header_buf);
if (!tape_weof(self->fd, 1)) {
}
d_self->access_mode = mode;
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = FALSE;
+ g_mutex_unlock(d_self->device_mutex);
if (IS_WRITABLE_ACCESS_MODE(mode)) {
if (self->write_open_errno != 0) {
amfree(amanda_header);
/* arrange the file numbers correctly */
- d_self->in_file = TRUE;
d_self->block = 0;
if (d_self->file >= 0)
d_self->file ++;
+ g_mutex_lock(d_self->device_mutex);
+ d_self->in_file = TRUE;
+ d_self->bytes_written = 0;
+ g_mutex_unlock(d_self->device_mutex);
return TRUE;
}
return FALSE;
}
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = FALSE;
+ g_mutex_unlock(d_self->device_mutex);
return TRUE;
}
difference --;
}
- d_self->in_file = FALSE;
d_self->is_eof = FALSE;
d_self->block = 0;
+ g_mutex_lock(d_self->device_mutex);
+ d_self->in_file = FALSE;
+ d_self->bytes_read = 0;
+ g_mutex_unlock(d_self->device_mutex);
reseek:
if (difference > 0) {
return NULL;
}
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = TRUE;
+ g_mutex_unlock(d_self->device_mutex);
d_self->file = file;
return rval;
}
/* Polish off this file, if relevant. */
+ g_mutex_lock(d_self->device_mutex);
if (d_self->in_file && IS_WRITABLE_ACCESS_MODE(d_self->access_mode)) {
- if (!device_finish_file(d_self))
+ g_mutex_unlock(d_self->device_mutex);
+ if (!device_finish_file(d_self)) {
goto finish_error;
+ }
+ } else {
+ g_mutex_unlock(d_self->device_mutex);
}
/* Straighten out the filemarks. We already wrote one in finish_file, and