-static gboolean
-property_get_free_space_fn(Device *dself,
- DevicePropertyBase *base G_GNUC_UNUSED, GValue *val,
- PropertySurety *surety, PropertySource *source)
-{
- RaitDevice *self = RAIT_DEVICE(dself);
- QualifiedSize result;
- guint i;
- GPtrArray * ops;
- guint data_children;
-
- ops = make_property_op_array(self, PROPERTY_MEDIUM_ACCESS_TYPE, NULL, 0, 0);
- do_rait_child_ops(self, property_get_do_op, ops);
-
- /* Find the minimal available space of any child, with some funny business
- * to deal with varying degrees of accuracy. */
- result.accuracy = SIZE_ACCURACY_UNKNOWN;
- result.bytes = 0;
- for (i = 0; i < ops->len; i ++) {
- QualifiedSize cur;
- PropertyOp * op = g_ptr_array_index(ops, i);
-
- if (!op->base.result || G_VALUE_TYPE(&(op->value)) != QUALIFIED_SIZE_TYPE) {
- /* maybe this child can't tell us .. so this is just an estimate */
- if (result.accuracy == SIZE_ACCURACY_REAL)
- result.accuracy = SIZE_ACCURACY_ESTIMATE;
-
- continue;
- }
-
- cur = *(QualifiedSize*)(g_value_get_boxed(&(op->value)));
-
- if (result.accuracy != cur.accuracy) {
- result.accuracy = SIZE_ACCURACY_ESTIMATE;
- }
-
- if (result.accuracy == SIZE_ACCURACY_UNKNOWN &&
- cur.accuracy != SIZE_ACCURACY_UNKNOWN) {
- result.bytes = cur.bytes;
- } else if (result.accuracy != SIZE_ACCURACY_UNKNOWN &&
- cur.accuracy == SIZE_ACCURACY_UNKNOWN) {
- /* result.bytes unchanged. */
- } else {
- result.bytes = MIN(result.bytes, cur.bytes);
- }
- }
-
- g_ptr_array_free_full(ops);
-
- /* result contains the minimum size available on any child. We
- * can use that space on each of our data children, so the total
- * is larger */
- find_simple_params(self, NULL, &data_children);
- result.bytes *= data_children;
-
- if (val) {
- g_value_unset_init(val, QUALIFIED_SIZE_TYPE);
- g_value_set_boxed(val, &result);
- }
-
- if (surety)
- *surety = (result.accuracy == SIZE_ACCURACY_UNKNOWN)?
- PROPERTY_SURETY_BAD : PROPERTY_SURETY_GOOD;
-
- if (source)
- *source = PROPERTY_SOURCE_DETECTED;
-
- return TRUE;
-}
-