Merge tag 'upstream/3.3.1'
[debian/amanda] / device-src / ndmp-device.c
index 0fe626a8829e258ab317aa500306809e2f12d41f..f4e39bd29f0f83b9c27e16705557fe9b6c200f52 100644 (file)
@@ -1027,8 +1027,8 @@ listen_impl(
 
     /* then tell it to start listening */
     if (!ndmp_connection_mover_listen(self->ndmp,
-               for_writing? NDMP4_MOVER_MODE_READ : NDMP4_MOVER_MODE_WRITE,
-               NDMP4_ADDR_TCP,
+               for_writing? NDMP9_MOVER_MODE_READ : NDMP9_MOVER_MODE_WRITE,
+               NDMP9_ADDR_TCP,
                addrs)) {
        set_error_from_ndmp(self);
        return FALSE;
@@ -1076,7 +1076,7 @@ accept_impl(
                return FALSE;
            }
 
-           if (state != NDMP4_MOVER_STATE_LISTEN)
+           if (state != NDMP9_MOVER_STATE_LISTEN)
                break;
 
            /* back off a little bit to give the other side time to breathe,
@@ -1088,7 +1088,7 @@ accept_impl(
        }
 
        /* double-check state */
-       if (state != NDMP4_MOVER_STATE_ACTIVE) {
+       if (state != NDMP9_MOVER_STATE_ACTIVE) {
            device_set_error(DEVICE(self),
                g_strdup("mover did not enter the ACTIVE state as expected"),
                DEVICE_STATUS_DEVICE_ERROR);
@@ -1136,9 +1136,9 @@ accept_impl(
     self->listen_addrs = NULL;
 
     if (self->for_writing)
-       mode = NDMP4_MOVER_MODE_READ;
+       mode = NDMP9_MOVER_MODE_READ;
     else
-       mode = NDMP4_MOVER_MODE_WRITE;
+       mode = NDMP9_MOVER_MODE_WRITE;
 
     /* set up the new directtcp connection */
     if (self->directtcp_conn)
@@ -1197,9 +1197,9 @@ connect_impl(
     }
 
     if (self->for_writing)
-       mode = NDMP4_MOVER_MODE_READ;
+       mode = NDMP9_MOVER_MODE_READ;
     else
-       mode = NDMP4_MOVER_MODE_WRITE;
+       mode = NDMP9_MOVER_MODE_WRITE;
 
     if (!ndmp_connection_mover_connect(self->ndmp, mode, addrs)) {
        set_error_from_ndmp(self);
@@ -1283,7 +1283,7 @@ write_from_connection_impl(
     /* if this is false, then the caller did not use use_connection correctly */
     g_assert(self->directtcp_conn != NULL);
     g_assert(self->ndmp == nconn->ndmp);
-    g_assert(nconn->mode == NDMP4_MOVER_MODE_READ);
+    g_assert(nconn->mode == NDMP9_MOVER_MODE_READ);
 
     if (!ndmp_connection_mover_get_state(self->ndmp,
                &mover_state, &bytes_moved_before, NULL, NULL)) {
@@ -1292,7 +1292,7 @@ write_from_connection_impl(
     }
 
     /* the mover had best be PAUSED right now */
-    g_assert(mover_state == NDMP4_MOVER_STATE_PAUSED);
+    g_assert(mover_state == NDMP9_MOVER_STATE_PAUSED);
 
     if (!ndmp_connection_mover_set_window(self->ndmp,
                nconn->offset,
@@ -1410,7 +1410,7 @@ read_to_connection_impl(
     /* if this is false, then the caller did not use use_connection correctly */
     g_assert(nconn != NULL);
     g_assert(self->ndmp == nconn->ndmp);
-    g_assert(nconn->mode == NDMP4_MOVER_MODE_WRITE);
+    g_assert(nconn->mode == NDMP9_MOVER_MODE_WRITE);
 
     if (!ndmp_connection_mover_get_state(self->ndmp,
                &mover_state, &bytes_moved_before, NULL, NULL)) {
@@ -1419,7 +1419,7 @@ read_to_connection_impl(
     }
 
     /* the mover had best be PAUSED right now */
-    g_assert(mover_state == NDMP4_MOVER_STATE_PAUSED);
+    g_assert(mover_state == NDMP9_MOVER_STATE_PAUSED);
 
     if (!ndmp_connection_mover_set_window(self->ndmp,
                nconn->offset,
@@ -1628,8 +1628,12 @@ ndmp_device_set_read_block_size_fn(Device *p_self, DevicePropertyBase *base G_GN
 
     if (read_block_size != 0 &&
            ((gsize)read_block_size < p_self->block_size ||
-            (gsize)read_block_size > p_self->max_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 '%zu', 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->read_block_size = read_block_size;
 
@@ -1816,10 +1820,8 @@ ndmp_device_factory(
     char *device_node)
 {
     Device *rval;
-    NdmpDevice * ndmp_rval;
     g_assert(0 == strcmp(device_type, NDMP_DEVICE_NAME));
     rval = DEVICE(g_object_new(TYPE_NDMP_DEVICE, NULL));
-    ndmp_rval = (NdmpDevice *)rval;
 
     device_open_device(rval, device_name, device_type, device_node);
     return rval;