/*
- * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+ * Copyright (c) 2007, 2008, 2009, 2010, 2011 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
static gboolean vfs_device_set_max_volume_usage_fn(Device *p_self,
DevicePropertyBase *base, GValue *val,
PropertySurety surety, PropertySource source);
+static gboolean vfs_device_set_enforce_max_volume_usage_fn(Device *p_self,
+ DevicePropertyBase *base, GValue *val,
+ PropertySurety surety, PropertySource source);
static gboolean property_get_monitor_free_space_fn(Device *p_self,
DevicePropertyBase *base, GValue *val,
PropertySurety *surety, PropertySource *source);
self->volume_bytes = 0;
self->volume_limit = 0;
self->leom = TRUE;
+ self->enforce_volume_limit = TRUE;
self->monitor_free_space = TRUE;
self->checked_fs_free_bytes = G_MAXUINT64;
g_value_unset(&response);
g_value_init(&response, G_TYPE_BOOLEAN);
- g_value_set_boolean(&response, FALSE);
+ g_value_set_boolean(&response, TRUE);
device_set_simple_property(dself, PROPERTY_LEOM,
&response, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DETECTED);
g_value_unset(&response);
+ g_value_init(&response, G_TYPE_BOOLEAN);
+ g_value_set_boolean(&response, TRUE);
+ device_set_simple_property(dself, PROPERTY_ENFORCE_MAX_VOLUME_USAGE,
+ &response, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DETECTED);
+ g_value_unset(&response);
+
g_value_init(&response, G_TYPE_BOOLEAN);
g_value_set_boolean(&response, FALSE);
device_set_simple_property(dself, PROPERTY_COMPRESSION,
device_simple_property_get_fn,
vfs_device_set_max_volume_usage_fn);
+ device_class_register_property(device_class, PROPERTY_ENFORCE_MAX_VOLUME_USAGE,
+ (PROPERTY_ACCESS_GET_MASK | PROPERTY_ACCESS_SET_MASK) &
+ (~ PROPERTY_ACCESS_SET_INSIDE_FILE_WRITE),
+ device_simple_property_get_fn,
+ vfs_device_set_enforce_max_volume_usage_fn);
+
device_class_register_property(device_class, PROPERTY_COMPRESSION,
PROPERTY_ACCESS_GET_MASK,
device_simple_property_get_fn,
return device_simple_property_set_fn(p_self, base, val, surety, source);
}
+static gboolean
+vfs_device_set_enforce_max_volume_usage_fn(Device *p_self,
+ DevicePropertyBase *base, GValue *val,
+ PropertySurety surety, PropertySource source)
+{
+ VfsDevice *self = VFS_DEVICE(p_self);
+
+ self->enforce_volume_limit = g_value_get_boolean(val);
+
+ return device_simple_property_set_fn(p_self, base, val, surety, source);
+}
+
static gboolean
property_get_monitor_free_space_fn(Device *p_self, DevicePropertyBase *base G_GNUC_UNUSED,
GValue *val, PropertySurety *surety, PropertySource *source)
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);
- d_self = DEVICE(self);
/* Skip the volume lock. */
if (strcmp(filename, VOLUME_LOCKFILE_NAME) == 0)
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;
}
/* update our state */
+ if (requested_file == 0) {
+ dself->header_block_size = header_buffer_size;
+ }
dself->in_file = TRUE;
dself->file = file;
return FALSE;
/* handle VOLUME_LIMIT */
- if (self->volume_limit &&
+ if (self->enforce_volume_limit && self->volume_limit &&
self->volume_bytes + size + eom_warning_buffer > self->volume_limit) {
return TRUE;
}
static gboolean
check_at_peom(VfsDevice *self, guint64 size)
{
- if (self->volume_limit > 0) {
+ if (self->enforce_volume_limit && (self->volume_limit > 0)) {
guint64 newtotal = self->volume_bytes + size;
if (newtotal > self->volume_limit) {
return TRUE;
vfs_device_erase (Device * dself) {
VfsDevice *self = VFS_DEVICE(dself);
- if (!open_lock(self, 0, true))
- return false;
+ if (!open_lock(self, 0, TRUE))
+ return FALSE;
delete_vfs_files(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;
}