From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1K5QHd-0001Y8-4m for garchives@archives.gentoo.org; Sun, 08 Jun 2008 19:10:29 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2ABF5E03FC; Sun, 8 Jun 2008 19:10:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B2694E03FC for ; Sun, 8 Jun 2008 19:10:27 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 4291266985 for ; Sun, 8 Jun 2008 19:10:27 +0000 (UTC) Received: from robbat2 by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1K5QHX-0005R2-5L for gentoo-commits@lists.gentoo.org; Sun, 08 Jun 2008 19:10:23 +0000 From: "Robin H. Johnson (robbat2)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, robbat2@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in sys-fs/device-mapper/files: device-mapper-1.02.26-export-format.diff X-VCS-Repository: gentoo-x86 X-VCS-Files: device-mapper-1.02.26-export-format.diff X-VCS-Directories: sys-fs/device-mapper/files X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson Content-Type: text/plain; charset=utf8 Message-Id: Sender: "Robin H. Johnson" Date: Sun, 08 Jun 2008 19:10:23 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 59067c31-b177-4f0b-8ebb-5d5e114fb3a0 X-Archives-Hash: ba17909c3639e8aa4004487746f542ee robbat2 08/06/08 19:10:23 Added: device-mapper-1.02.26-export-format.diff Log: Version bump, with new output-field-name prefix support. (Portage version: 2.1.5.4) Revision Changes Path 1.1 sys-fs/device-mapper/files/device-mapper-1.02.26-exp= ort-format.diff file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/device-mapp= er/files/device-mapper-1.02.26-export-format.diff?rev=3D1.1&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/device-mapp= er/files/device-mapper-1.02.26-export-format.diff?rev=3D1.1&content-type=3D= text/plain Index: device-mapper-1.02.26-export-format.diff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff -Nuar --exclude '*.orig' device-mapper.1.02.26.orig/dmsetup/dmsetup.= c device-mapper.1.02.26/dmsetup/dmsetup.c --- device-mapper.1.02.26.orig/dmsetup/dmsetup.c 2008-06-06 11:53:08.0000= 00000 -0700 +++ device-mapper.1.02.26/dmsetup/dmsetup.c 2008-06-08 11:57:58.491838798= -0700 @@ -108,6 +108,7 @@ enum { READ_ONLY =3D 0, COLS_ARG, + EXPORT_ARG, EXEC_ARG, FORCE_ARG, GID_ARG, @@ -140,7 +141,8 @@ DR_TASK =3D 1, DR_INFO =3D 2, DR_DEPS =3D 4, - DR_TREE =3D 8 /* Complete dependency tree required */ + DR_TREE =3D 8, /* Complete dependency tree required */ + DR_TABLE =3D 0x10, /* table is required, not just info */ } report_type_t; =20 static int _switches[NUM_SWITCHES]; @@ -1124,8 +1126,13 @@ name =3D argv[1]; } =20 - if (!(dmt =3D dm_task_create(DM_DEVICE_INFO))) - return 0; + if (_report_type & DR_TABLE ) { + if (!(dmt =3D dm_task_create(DM_DEVICE_TABLE))) + return 0; + } else { + if (!(dmt =3D dm_task_create(DM_DEVICE_INFO))) + return 0; + } =20 if (!_set_task_device(dmt, name, 0)) goto out; @@ -1589,6 +1596,16 @@ return dm_report_field_uint32(rh, field, &value); } =20 +static int _int_disp(struct dm_report *rh, + struct dm_pool *mem __attribute((unused)), + struct dm_report_field *field, const void *data, + void *private __attribute((unused))) +{ + const int value =3D *(const int *)data; + + return dm_report_field_int(rh, field, &value); +} + static int _dm_name_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)), struct dm_report_field *field, const void *data, @@ -1700,6 +1717,66 @@ } =20 =20 +static int _dm_info_cleartext_status_disp(struct dm_report *rh, + struct dm_pool *mem __attribute((unused)), + struct dm_report_field *field, const void *data, + void *private __attribute((unused))) +{ + const char *buf =3D "NOTPRESENT"; + const struct dm_info *info =3D data; + + if (info->exists) { + if (info->suspended) + buf =3D "SUSPENDED"; + else + buf =3D info->read_only ? " READONLY" : "ACTIVE"; + } + =09 + return dm_report_field_string(rh, field, &buf); +} + +static int _dm_info_target_types_disp(struct dm_report *rh, + struct dm_pool *mem __attribute((unused)), + struct dm_report_field *field, const void *data, + void *private __attribute((unused))) +{ + char buf[1024]; + char *dest =3D buf; + int remains =3D sizeof(buf); + int written; + const char *s =3D buf; + struct dm_task *dmt =3D (struct dm_task *) data; + void *next =3D NULL; + uint64_t start, length; + char *target_type =3D NULL; + char *params; + + + buf[0] =3D '\0'; +=09 + next =3D dm_get_next_target(dmt, next, &start, &length, + &target_type, ¶ms); + if (target_type) { + written =3D snprintf(dest, remains, "%s", target_type); + dest +=3D written; + remains -=3D written; + + while (remains > 0 && next) { + next =3D dm_get_next_target(dmt, next, &start, &length, + &target_type, ¶ms); + if (target_type) { + written =3D snprintf(dest, remains, ",%s", target_type); + dest +=3D written; + remains -=3D written; + } + } + } + + buf[sizeof(buf)-1] =3D '\0'; +=09 + return dm_report_field_string(rh, field, &s); +} + static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem= , struct dm_report_field *field, const void *data, void *private) @@ -1923,11 +2000,12 @@ { DR_INFO, "Mapped Device Information", "", _info_get_obj }, { DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj = }, { DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj = }, + { DR_TABLE, "Mapped Device Table", "", _task_get_obj }, { 0, "", "", NULL }, }; =20 /* Column definitions */ -#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)-= >field) +#define OFFSET_OF(strct, field) ((unsigned long) &((struct strct *)NULL)= ->field) #define STR (DM_REPORT_FIELD_TYPE_STRING) #define NUM (DM_REPORT_FIELD_TYPE_NUMBER) #define FIELD_O(type, strct, sorttype, head, field, width, func, id, des= c) {DR_ ## type, sorttype, OFFSET_OF(strct, field), width, id, head, &_ #= # func ## _disp, desc}, @@ -1942,6 +2020,7 @@ FIELD_F(TASK, NUM, "RAhead", 6, dm_read_ahead, "read_ahead", "Read ahead= in sectors.") =20 FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "attr", "(L)ive, (I)nactiv= e, (s)uspended, (r)ead-only, read-(w)rite.") +FIELD_F(INFO, STR, "State", 1, dm_info_cleartext_status, "status", "Stat= e as cleartext.") FIELD_F(INFO, STR, "Tables", 6, dm_info_table_loaded, "tables_loaded", "= Which of the live and inactive table slots are filled.") FIELD_F(INFO, STR, "Suspended", 9, dm_info_suspended, "suspended", "Whet= her the device is suspended.") FIELD_F(INFO, STR, "Read-only", 9, dm_info_read_only, "readonly", "Wheth= er the device is read-only or writeable.") @@ -1952,6 +2031,11 @@ FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "segments", = "Number of segments in live table, if present.") FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Num= ber of most recent event.") =20 +FIELD_O(INFO, dm_info, NUM, "RO", read_only, 2, int, "read_only", "Read = only.") +FIELD_O(INFO, dm_info, NUM, "Ex", exists, 2, int, "exists", "Exists.") +FIELD_O(INFO, dm_info, NUM, "Susp", suspended, 4, int, "suspended", "Sus= pended.") +FIELD_O(INFO, dm_info, NUM, "tab_live", live_table, 8, int, "table_live"= , "Live table.") +FIELD_O(INFO, dm_info, NUM, "tab_inact", inactive_table, 9, int, "table_= inactive", "Inactive table.") FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "N= umber of devices used by this one.") FIELD_F(TREE, STR, "DevNames", 8, dm_deps_names, "devs_used", "List of n= ames of mapped devices used by this one.") FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device = numbers of devices used by this one.") @@ -1959,6 +2043,7 @@ FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count"= , "Number of mapped devices referencing this one.") FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_de= v", "List of names of mapped devices using this one.") FIELD_F(TREE, STR, "RefDevNos", 9, dm_tree_parents_devs, "devnos_using_d= ev", "List of device numbers of mapped devices using this one.") +FIELD_F(TABLE, STR, "Targettypes", 32, dm_info_target_types, "target_typ= es", "Used target types.") {0, 0, 0, 0, "", "", NULL, NULL}, /* *INDENT-ON* */ }; @@ -1969,13 +2054,15 @@ #undef FIELD_F =20 static const char *default_report_options =3D "name,major,minor,attr,ope= n,segments,events,uuid"; +static const char *default_export_options =3D "name,major,minor,status,r= ead_only,exists,suspended,table_live,table_inactive,open,segments,events,= uuid,target_types"; =20 static int _report_init(struct command *c) { - char *options =3D (char *) default_report_options; + char *default_options =3D (char *) default_report_options; + char *options; const char *keys =3D ""; const char *separator =3D " "; - int aligned =3D 1, headings =3D 1, buffered =3D 1, field_prefixes =3D 0= ; + int aligned =3D 1, headings =3D 1, buffered =3D 1, field_prefixes =3D 0= , export =3D 0; uint32_t flags =3D 0; size_t len =3D 0; int r =3D 0; @@ -1995,6 +2082,15 @@ field_prefixes =3D 1; } =20 + if (_switches[EXPORT_ARG]) { + default_options =3D (char *) default_export_options; + separator =3D "\n"; + aligned =3D 0; + headings =3D 0; + export =3D 1; + } + + options =3D default_options; if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) { if (*_string_args[OPTIONS_ARG] !=3D '+') options =3D _string_args[OPTIONS_ARG]; @@ -2040,6 +2136,9 @@ if (field_prefixes) flags |=3D DM_REPORT_OUTPUT_FIELD_NAME_PREFIX; =20 + if (export) + flags |=3D DM_REPORT_OUTPUT_EXPORT; + if (!(_report =3D dm_report_init(&_report_type, _report_types, _report_fields, options, separator, flags, keys, NULL))) @@ -2118,7 +2217,8 @@ fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs]\n" " [--readahead [+]|auto|none]\n" - " [-c|-C|--columns] [-o ] [-O|--sort ]\n" + " [-c|-C|--columns] [-e|--export]\n" + " [-o ] [-O|--sort ]\n" " [--nameprefixes] [--noheadings] [--separator ]\n\n= "); for (i =3D 0; _commands[i].name; i++) fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help); @@ -2469,6 +2569,7 @@ static struct option long_options[] =3D { {"readonly", 0, &ind, READ_ONLY}, {"columns", 0, &ind, COLS_ARG}, + {"export", 0, &ind, EXPORT_ARG}, {"exec", 1, &ind, EXEC_ARG}, {"force", 0, &ind, FORCE_ARG}, {"gid", 1, &ind, GID_ARG}, @@ -2549,12 +2650,16 @@ =20 optarg =3D 0; optind =3D OPTIND_INIT; - while ((ind =3D -1, c =3D GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:O:ru= :Uv", + while ((ind =3D -1, c =3D GETOPTLONG_FN(*argc, *argv, "cCefGj:m:Mno:O:r= u:Uv", long_options, NULL)) !=3D -1) { if (c =3D=3D ':' || c =3D=3D '?') return 0; if (c =3D=3D 'c' || c =3D=3D 'C' || ind =3D=3D COLS_ARG) _switches[COLS_ARG]++; + if (c =3D=3D 'e' || ind =3D=3D EXPORT_ARG) { + _switches[EXPORT_ARG]++; + _switches[COLS_ARG]++; + } if (c =3D=3D 'f' || ind =3D=3D FORCE_ARG) _switches[FORCE_ARG]++; if (c =3D=3D 'r' || ind =3D=3D READ_ONLY) diff -Nuar --exclude '*.orig' device-mapper.1.02.26.orig/lib/libdevmapper= .h device-mapper.1.02.26/lib/libdevmapper.h --- device-mapper.1.02.26.orig/lib/libdevmapper.h 2008-04-19 17:11:08.000= 000000 -0700 +++ device-mapper.1.02.26/lib/libdevmapper.h 2008-06-08 11:55:22.03961531= 4 -0700 @@ -740,6 +740,7 @@ #define DM_REPORT_OUTPUT_BUFFERED 0x00000002 #define DM_REPORT_OUTPUT_HEADINGS 0x00000004 #define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008 +#define DM_REPORT_OUTPUT_EXPORT 0x00000010 =20 struct dm_report *dm_report_init(uint32_t *report_types, const struct dm_report_object_type *types, diff -Nuar --exclude '*.orig' device-mapper.1.02.26.orig/lib/libdm-report= .c device-mapper.1.02.26/lib/libdm-report.c --- device-mapper.1.02.26.orig/lib/libdm-report.c 2008-06-06 12:07:47.000= 000000 -0700 +++ device-mapper.1.02.26/lib/libdm-report.c 2008-06-08 11:54:39.61823631= 3 -0700 @@ -13,6 +13,7 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ =20 +#include #include "libdevmapper.h" #include "list.h" #include "log.h" @@ -803,6 +804,8 @@ char buf[4096]; int32_t width; uint32_t align; + const char *fname; + char tmp_char; =20 if (list_empty(&rh->rows)) return 1; @@ -851,6 +854,25 @@ } } =20 + if (rh->flags & DM_REPORT_OUTPUT_EXPORT) { + fname =3D rh->fields[field->props->field_num].id; + if (!dm_pool_grow_object(rh->mem, "DM_", strlen("DM_"))) { + log_error("dm_report: Unable to extend output line"); + goto bad; + } + while (fname && fname[0]) { + tmp_char =3D toupper(fname[0]); + if (!dm_pool_grow_object(rh->mem, &tmp_char, 1)) { + log_error("dm_report: Unable to extend output line"); + goto bad; + } + fname++; + } + if (!dm_pool_grow_object(rh->mem, "=3D", strlen("=3D"))) { + log_error("dm_report: Unable to extend output line"); + goto bad; + } + } repstr =3D field->report_string; width =3D field->props->width; if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) { --=20 gentoo-commits@lists.gentoo.org mailing list