projects
/
debian
/
amanda
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge tag 'upstream/3.3.3'
[debian/amanda]
/
device-src
/
vfs-device.c
diff --git
a/device-src/vfs-device.c
b/device-src/vfs-device.c
index 4906c29a02db60c2da0796170f78309ff89b4f8a..9952c39db45c51d13d4d4560f9eee7e54873bd91 100644
(file)
--- a/
device-src/vfs-device.c
+++ b/
device-src/vfs-device.c
@@
-1,9
+1,10
@@
/*
/*
- * Copyright (c) 2007
, 2008, 2009, 2010, 2011
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
- * by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@
-585,11
+586,9
@@
vfs_device_open_device (Device * pself, char * device_name, char * device_type,
static gboolean delete_vfs_files_functor(const char * filename,
gpointer user_data) {
VfsDevice * self;
static gboolean delete_vfs_files_functor(const char * filename,
gpointer user_data) {
VfsDevice * self;
- Device * d_self;
char * path_name;
self = VFS_DEVICE(user_data);
char * path_name;
self = VFS_DEVICE(user_data);
- d_self = DEVICE(self);
/* Skip the volume lock. */
if (strcmp(filename, VOLUME_LOCKFILE_NAME) == 0)
/* Skip the volume lock. */
if (strcmp(filename, VOLUME_LOCKFILE_NAME) == 0)
@@
-691,6
+690,7
@@
static gboolean clear_and_prepare_label(VfsDevice * self, char * label,
return FALSE;
}
dumpfile_free(d_self->volume_header);
return FALSE;
}
dumpfile_free(d_self->volume_header);
+ d_self->header_block_size = VFS_DEVICE_LABEL_SIZE;
d_self->volume_header = label_header;
self->volume_bytes = VFS_DEVICE_LABEL_SIZE;
return TRUE;
d_self->volume_header = label_header;
self->volume_bytes = VFS_DEVICE_LABEL_SIZE;
return TRUE;
@@
-796,9
+796,10
@@
static gboolean vfs_device_write_block(Device * pself, guint size, gpointer data
pself->is_eom = TRUE;
if (check_at_peom(self, size)) {
pself->is_eom = TRUE;
if (check_at_peom(self, size)) {
+ /* check_at_peom() only checks against MAX_VOLUME_USAGE limit */
pself->is_eom = TRUE;
device_set_error(pself,
pself->is_eom = TRUE;
device_set_error(pself,
- stralloc(_("No space left on device")),
+ stralloc(_("No space left on device
: more than MAX_VOLUME_USAGE bytes written
")),
DEVICE_STATUS_VOLUME_ERROR);
return FALSE;
}
DEVICE_STATUS_VOLUME_ERROR);
return FALSE;
}
@@
-812,6
+813,9
@@
static gboolean vfs_device_write_block(Device * pself, guint size, gpointer data
self->volume_bytes += size;
self->checked_bytes_used += size;
pself->block ++;
self->volume_bytes += size;
self->checked_bytes_used += size;
pself->block ++;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_written += size;
+ g_mutex_unlock(pself->device_mutex);
return TRUE;
}
return TRUE;
}
@@
-838,11
+842,16
@@
vfs_device_read_block(Device * pself, gpointer data, int * size_req) {
switch (result) {
case RESULT_SUCCESS:
*size_req = size;
switch (result) {
case RESULT_SUCCESS:
*size_req = size;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_read += size;
+ g_mutex_unlock(pself->device_mutex);
pself->block++;
return size;
case RESULT_NO_DATA:
pself->is_eof = TRUE;
pself->block++;
return size;
case RESULT_NO_DATA:
pself->is_eof = TRUE;
+ g_mutex_lock(pself->device_mutex);
pself->in_file = FALSE;
pself->in_file = FALSE;
+ g_mutex_unlock(pself->device_mutex);
device_set_error(pself,
stralloc(_("EOF")),
DEVICE_STATUS_SUCCESS);
device_set_error(pself,
stralloc(_("EOF")),
DEVICE_STATUS_SUCCESS);
@@
-868,7
+877,9
@@
vfs_device_start(Device * dself,
return FALSE;
}
return FALSE;
}
+ g_mutex_lock(dself->device_mutex);
dself->in_file = FALSE;
dself->in_file = FALSE;
+ g_mutex_unlock(dself->device_mutex);
if (mode == ACCESS_WRITE) {
promote_volume_lock(self);
if (mode == ACCESS_WRITE) {
promote_volume_lock(self);
@@
-908,7
+919,9
@@
vfs_device_finish (Device * pself) {
release_file(self);
pself->access_mode = ACCESS_NULL;
release_file(self);
pself->access_mode = ACCESS_NULL;
+ g_mutex_lock(pself->device_mutex);
pself->in_file = FALSE;
pself->in_file = FALSE;
+ g_mutex_unlock(pself->device_mutex);
if (device_in_error(self)) return FALSE;
if (device_in_error(self)) return FALSE;
@@
-1060,9
+1073,10
@@
vfs_device_start_file (Device * dself, dumpfile_t * ji) {
dself->is_eom = TRUE;
if (check_at_peom(self, VFS_DEVICE_LABEL_SIZE)) {
dself->is_eom = TRUE;
if (check_at_peom(self, VFS_DEVICE_LABEL_SIZE)) {
+ /* check_at_peom() only checks against MAX_VOLUME_USAGE limit */
dself->is_eom = TRUE;
device_set_error(dself,
dself->is_eom = TRUE;
device_set_error(dself,
- stralloc(_("No space left on device")),
+ stralloc(_("No space left on device
: more than MAX_VOLUME_USAGE bytes written
")),
DEVICE_STATUS_DEVICE_ERROR);
return FALSE;
}
DEVICE_STATUS_DEVICE_ERROR);
return FALSE;
}
@@
-1103,8
+1117,11
@@
vfs_device_start_file (Device * dself, dumpfile_t * ji) {
/* handle some accounting business */
self->volume_bytes += VFS_DEVICE_LABEL_SIZE;
self->checked_bytes_used += VFS_DEVICE_LABEL_SIZE;
/* handle some accounting business */
self->volume_bytes += VFS_DEVICE_LABEL_SIZE;
self->checked_bytes_used += VFS_DEVICE_LABEL_SIZE;
- dself->in_file = TRUE;
dself->block = 0;
dself->block = 0;
+ g_mutex_lock(dself->device_mutex);
+ dself->in_file = TRUE;
+ dself->bytes_written = 0;
+ g_mutex_unlock(dself->device_mutex);
/* make_new_file_name set pself->file for us */
return TRUE;
/* make_new_file_name set pself->file for us */
return TRUE;
@@
-1118,7
+1135,9
@@
vfs_device_finish_file(Device * dself) {
release_file(self);
release_file(self);
+ g_mutex_lock(dself->device_mutex);
dself->in_file = FALSE;
dself->in_file = FALSE;
+ g_mutex_unlock(dself->device_mutex);
return TRUE;
}
return TRUE;
}
@@
-1138,9
+1157,12
@@
vfs_device_seek_file (Device * dself, guint requested_file) {
if (device_in_error(self)) return NULL;
if (device_in_error(self)) return NULL;
- dself->in_file = FALSE;
dself->is_eof = FALSE;
dself->block = 0;
dself->is_eof = FALSE;
dself->block = 0;
+ g_mutex_lock(dself->device_mutex);
+ dself->in_file = FALSE;
+ dself->bytes_read = 0;
+ g_mutex_unlock(dself->device_mutex);
release_file(self);
release_file(self);
@@
-1230,7
+1252,12
@@
vfs_device_seek_file (Device * dself, guint requested_file) {
}
/* update our state */
}
/* update our state */
+ if (requested_file == 0) {
+ dself->header_block_size = header_buffer_size;
+ }
+ g_mutex_lock(dself->device_mutex);
dself->in_file = TRUE;
dself->in_file = TRUE;
+ g_mutex_unlock(dself->device_mutex);
dself->file = file;
return rval;
dself->file = file;
return rval;
@@
-1404,6
+1431,11
@@
vfs_device_erase (Device * dself) {
release_file(self);
release_file(self);
+ dumpfile_free(dself->volume_header);
+ dself->volume_header = NULL;
+ device_set_error(dself, g_strdup("Unlabeled volume"),
+ DEVICE_STATUS_VOLUME_UNLABELED);
+
return TRUE;
}
return TRUE;
}