Module Name:    src
Committed By:   tkusumi
Date:           Sat Dec 14 17:15:54 UTC 2019

Modified Files:
        src/sys/dev/dm: dm.h dm_ioctl.c

Log Message:
dm: Don't try to implement "status" as subset of "table"

The way dm_table_status_ioctl() implements "status" and "table" is
not compatible with Linux kernel. Some targets have different outputs
that "status" can't be implemented as subset of "table".

Add ->info() handler to sync with "status" behavior in Linux kernel.
Some targets which currently exist in NetBSD (I think striped)
as well as some minor targets that I plan to port to NetBSD
can/should implement ->info(), but will do that in a different commit.

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/dm/dm.h
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/dm/dm_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/dm/dm.h
diff -u src/sys/dev/dm/dm.h:1.40 src/sys/dev/dm/dm.h:1.41
--- src/sys/dev/dm/dm.h:1.40	Sat Dec 14 11:20:51 2019
+++ src/sys/dev/dm/dm.h	Sat Dec 14 17:15:54 2019
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.40 2019/12/14 11:20:51 tkusumi Exp $      */
+/*        $NetBSD: dm.h,v 1.41 2019/12/14 17:15:54 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -184,10 +184,11 @@ typedef struct dm_target {
 
 	int (*deps) (dm_table_entry_t *, prop_array_t);
 	/*
-	 * Status routine is called to get params string, which is target
+	 * Info/status routine are called to get params string, which is target
 	 * specific. When dm_table_status_ioctl is called with flag
 	 * DM_STATUS_TABLE_FLAG I have to sent params string back.
 	 */
+	char *(*info)(void *);
 	char * (*status)(void *);
 	int (*strategy)(dm_table_entry_t *, struct buf *);
 	int (*sync)(dm_table_entry_t *);

Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.43 src/sys/dev/dm/dm_ioctl.c:1.44
--- src/sys/dev/dm/dm_ioctl.c:1.43	Sat Dec 14 14:43:38 2019
+++ src/sys/dev/dm/dm_ioctl.c	Sat Dec 14 17:15:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.43 2019/12/14 14:43:38 tkusumi Exp $      */
+/* $NetBSD: dm_ioctl.c,v 1.44 2019/12/14 17:15:54 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.43 2019/12/14 14:43:38 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.44 2019/12/14 17:15:54 tkusumi Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -942,17 +942,21 @@ dm_table_status_ioctl(prop_dictionary_t 
 		 */
 		prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, "");
 
-		if (flags & DM_STATUS_TABLE_FLAG) {
-			params = table_en->target->status
-			    (table_en->target_config);
-
-			if (params != NULL) {
-				prop_dictionary_set_cstring(target_dict,
-				    DM_TABLE_PARAMS, params);
+		if (flags & DM_STATUS_TABLE_FLAG)
+			params = table_en->target->status(
+			    table_en->target_config);
+		else if (table_en->target->info)
+			params = table_en->target->info(
+			    table_en->target_config);
+		else
+			params = NULL;
 
-				kmem_free(params, DM_MAX_PARAMS_SIZE);
-			}
+		if (params != NULL) {
+			prop_dictionary_set_cstring(target_dict,
+			    DM_TABLE_PARAMS, params);
+			kmem_free(params, DM_MAX_PARAMS_SIZE);
 		}
+
 		prop_array_add(cmd_array, target_dict);
 		prop_object_release(target_dict);
 	}

Reply via email to