Add vsprintf extension %pU to print UUID/GUIDs and use it
Subsystems (12)
PATCH 9/9 fs/xfs/xfs_log_recover.c: Use %pU to print UUIDs
In reply to Joe Perches--- fs/xfs/xfs_log_recover.c | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-)
fs/xfs/xfs_log_recover.c +4 -10
@@ -225,16 +225,10 @@ xlog_header_check_dump( xfs_mount_t *mp, xlog_rec_header_t *head) { -int b; - -cmn_err (CE_DEBUG ,"%s: SB : uuid = " , __func__); -for (b =0 ; b <16 ; b++) -cmn_err (CE_DEBUG ,"%02x" , ((__uint8_t *)&mp->m_sb.sb_uuid)[b]); -cmn_err (CE_DEBUG ,", fmt = %d\n" ,XLOG_FMT ); -cmn_err (CE_DEBUG ," log : uuid = " ); -for (b =0 ; b <16 ; b++) -cmn_err (CE_DEBUG ,"%02x" , ((__uint8_t *)&head->h_fs_uuid)[b]); -cmn_err (CE_DEBUG ,", fmt = %d\n" ,be32_to_cpu (head->h_fmt)); +cmn_err (CE_DEBUG ,"%s: SB : uuid = %pU, fmt = %d\n" , + __func__, &mp->m_sb.sb_uuid,XLOG_FMT ); +cmn_err (CE_DEBUG ," log : uuid = %pU, fmt = %d\n" , + &head->h_fs_uuid,be32_to_cpu (head->h_fmt)); }#else #define xlog_header_check_dump (mp, head)
Signature · 6 lines
1.6.3.1.10.g659a0.dirty _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/9 drivers/md/md.c: Use %pU to print UUIDs
In reply to Joe Perches--- drivers/md/md.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-)
drivers/md/md.c +4 -12
@@ -1813,15 +1813,11 @@ static void print_sb_1(struct mdp_superblock_1 *sb) uuid = sb->set_uuid;printk (KERN_INFO -"md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x" -":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n" +"md: SB: (V:%u) (F:0x%08x) Array-ID:<%pU>\n" "md: Name: \"%s\" CT:%llu\n" ,le32_to_cpu (sb->major_version),le32_to_cpu (sb->feature_map), - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], - uuid[4 ], uuid[5 ], uuid[6 ], uuid[7 ], - uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], - uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ], + uuid, sb->set_name, (unsigned long long )le64_to_cpu (sb->ctime) &MD_SUPERBLOCK_1_TIME_SEC_MASK );
@@ -1830,8 +1826,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb) printk(KERN_INFO "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu" " RO:%llu\n" - "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x" - ":%02x%02x%02x%02x%02x%02x\n" + "md: Dev:%08x UUID: %pU\n" "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n" "md: (MaxDev:%u) \n", le32_to_cpu(sb->level),
@@ -1844,10 +1839,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb) (unsigned long long )le64_to_cpu (sb->super_offset), (unsigned long long )le64_to_cpu (sb->recovery_offset),le32_to_cpu (sb->dev_number), - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], - uuid[4 ], uuid[5 ], uuid[6 ], uuid[7 ], - uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], - uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ], + uuid, sb->devflags, (unsigned long long )le64_to_cpu (sb->utime) &MD_SUPERBLOCK_1_TIME_SEC_MASK , (unsigned long long)le64_to_cpu(sb->events),
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 7/9 fs/gfs2/sys.c: Use %pUX to print UUIDs
In reply to Joe Perches--- fs/gfs2/sys.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-)
fs/gfs2/sys.c +3 -13
@@ -85,11 +85,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf) buf[0 ] ='\0' ;if (!gfs2_uuid_valid (uuid))return 0 ; -return snprintf (buf,PAGE_SIZE ,"%02X%02X%02X%02X-%02X%02X-" -"%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n" , - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], uuid[5 ], - uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], - uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ]); +return snprintf (buf,PAGE_SIZE ,"%pUX\n" , uuid); }static ssize_t freeze_show (struct gfs2_sbd *sdp,char *buf)
@@ -573,14 +569,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,add_uevent_var (env,"LOCKPROTO=%s" , sdp->sd_proto_name);if (!sdp->sd_args.ar_spectator)add_uevent_var (env,"JOURNALID=%u" , sdp->sd_lockstruct.ls_jid); -if (gfs2_uuid_valid (uuid)) { -add_uevent_var (env,"UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" -"%02X%02X-%02X%02X%02X%02X%02X%02X" , - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], - uuid[5 ], uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], - uuid[10 ], uuid[11 ], uuid[12 ], uuid[13 ], - uuid[14 ], uuid[15 ]); - } +if (gfs2_uuid_valid (uuid)) +add_uevent_var (env,"UUID=%pUX" , uuid);return 0 ; }
Signature · 1 line
1.6.3.1.10.g659a0.dirty
cover Add vsprintf extension %pU to print UUID/GUIDs and use it
It makes an x86 defconfig smaller compiled with gcc 4.4 smaller too
old:
$ size vmlinux text data bss dec hex filename 6981105 678300 1359668 9019073 899ec1 vmlinux
new:
$ size vmlinux text data bss dec hex filename 6980770 678380 1359668 9018818 899dc2 vmlinux
Joe Perches (9):
lib/vsprintf.c: Add %pU to print UUID/GUIDs efi.h: Use %pUr to print UUIDs
random.c: Use %pU to print UUIDs drivers/firmware/dmi_scan.c: Use %pUX to print UUIDs drivers/md/md.c: Use %pU to print UUIDs drivers/media/video/uvc: Use %pUr to print UUIDs fs/gfs2/sys.c: Use %pUX to print UUIDs fs/ubifs: Use %pUX to print UUIDs fs/xfs/xfs_log_recover.c: Use %pU to print UUIDs
drivers/char/random.c | 10 +--- drivers/firmware/dmi_scan.c | 5 +-- drivers/md/md.c | 16 ++------ drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------ drivers/media/video/uvc/uvc_driver.c | 7 +-- drivers/media/video/uvc/uvcvideo.h | 10 ----- fs/gfs2/sys.c | 16 +------ fs/ubifs/debug.c | 9 +--- fs/ubifs/super.c | 7 +--- fs/xfs/xfs_log_recover.c | 14 ++----- include/linux/efi.h | 6 +-- lib/vsprintf.c | 58 ++++++++++++++++++++++++++++- 12 files changed, 111 insertions(+), 116 deletions(-)
PATCH 1/9 lib/vsprintf.c: Add %pU to print UUID/GUIDs
UUID/GUIDs are somewhat common in kernel source.
Standardize the printed style of UUID/GUIDs by using another extension to %p.
%pU: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUr: 04030201-0605-0807-090a-0b0c0d0e0f10
%pU[r]X:Use upper case hex
--- lib/vsprintf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 57 insertions(+), 1 deletions(-)
lib/vsprintf.c +57 -1
@@ -790,6 +790,53 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,return string (buf, end, ip4_addr, spec); } +static char *uuid_string (char *buf,char *end,const u8 *addr, +struct printf_spec spec,const char *fmt) +{ +char uuid[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" )]; +char *p = uuid; +int i; +static const u8 r[16 ] = {3 ,2 ,1 ,0 ,5 ,4 ,7 ,6 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 }; +static const u8 n[16 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 }; +const u8 *index = n; +bool uc = false; + +while (isalnum (*(++fmt))) { +switch (*fmt) { +case 'r' : + index = r; +break ; +case 'X' : + uc = true; +break ; + } + } + +for (i =0 ; i <16 ; i++) { + p =pack_hex_byte (p, addr[index[i]]); +switch (i) { +case 3 : +case 5 : +case 7 : +case 9 : + *p++ ='-' ; +break ; + } + } + + *p =0 ; + +if (uc) { + p = uuid; +while (*p) { + *p =toupper (*p); + p++; + } + } + +return string (buf, end, uuid, spec); +} +/* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of alphanumeric characters that are extended format
@@ -814,6 +861,13 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,* IPv4 uses dot-separated decimal with leading 0's (010.123.045.006) * - 'I6c' for IPv6 addresses printed as specified by * http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt +* - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form +* "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +* Options for %pU are: +* 'X' use upper case hex digits +* 'r' use LE byte order for U32 and U16s equivalents. Use indices: +* [3][2][1][0]-[5][4]-[7][6]-[9][8]-[10]...[15] +* * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 * function pointers are really function descriptors, which contain a * pointer to the real address.
@@ -828,9 +882,9 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,case 'F' :case 'f' : ptr =dereference_function_descriptor (ptr); -case 's' :/* Fallthrough */ case 'S' : +case 's' :return symbol_string (buf, end, ptr, spec, *fmt);case 'R' :return resource_string (buf, end, ptr, spec);
@@ -853,6 +907,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,return ip4_addr_string (buf, end, ptr, spec, fmt); }break ; +case 'U' : +return uuid_string (buf, end, ptr, spec, fmt); } spec.flags |=SMALL ;if (spec.field_width ==-1 ) {
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 6/9 drivers/media/video/uvc: Use %pUr to print UUIDs
In reply to Joe Perches--- drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------ drivers/media/video/uvc/uvc_driver.c | 7 +-- drivers/media/video/uvc/uvcvideo.h | 10 ----- 3 files changed, 35 insertions(+), 51 deletions(-)
drivers/media/video/uvc/uvc_ctrl.c +32 -37
@@ -1093,8 +1093,8 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,if (!found) {uvc_trace (UVC_TRACE_CONTROL , -"Control " UVC_GUID_FORMAT "/%u not found.\n" , -UVC_GUID_ARGS (entity->extension.guidExtensionCode), +"Control %pUr/%u not found.\n" , + entity->extension.guidExtensionCode, xctrl->selector);return -EINVAL ; }
@@ -1171,9 +1171,9 @@ int uvc_ctrl_resume_device(struct uvc_device *dev) (ctrl->info->flags & UVC_CONTROL_RESTORE) == 0) continue; -printk (KERN_INFO "restoring control " UVC_GUID_FORMAT -"/%u/%u\n" ,UVC_GUID_ARGS (ctrl->info->entity), - ctrl->info->index, ctrl->info->selector); +printk (KERN_INFO "restoring control %pUr/%u/%u\n" , + ctrl->info->entity, + ctrl->info->index, ctrl->info->selector); ctrl->dirty =1 ; }
@@ -1228,46 +1228,43 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, dev->intfnum, info->selector, (__u8 *)&size, 2);if (ret <0 ) {uvc_trace (UVC_TRACE_CONTROL ,"GET_LEN failed on " -"control " UVC_GUID_FORMAT "/%u (%d).\n" , -UVC_GUID_ARGS (info->entity), info->selector, - ret); +"control %pUr/%u (%d).\n" , + info->entity, info->selector, ret);return ; }if (info->size !=le16_to_cpu (size)) { -uvc_trace (UVC_TRACE_CONTROL ,"Control " UVC_GUID_FORMAT -"/%u size doesn't match user supplied " -"value.\n" ,UVC_GUID_ARGS (info->entity), - info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u size doesn't match user supplied value.\n" , + info->entity, info->selector);return ; } ret =uvc_query_ctrl (dev,UVC_GET_INFO , ctrl->entity->id, dev->intfnum, info->selector, &inf,1 );if (ret <0 ) { -uvc_trace (UVC_TRACE_CONTROL ,"GET_INFO failed on " -"control " UVC_GUID_FORMAT "/%u (%d).\n" , -UVC_GUID_ARGS (info->entity), info->selector, - ret); +uvc_trace (UVC_TRACE_CONTROL , +"GET_INFO failed on control %pUr/%u (%d).\n" , + info->entity, info->selector, ret);return ; } flags = info->flags;if (((flags &UVC_CONTROL_GET_CUR ) && !(inf & (1 <<0 ))) || ((flags &UVC_CONTROL_SET_CUR ) && !(inf & (1 <<1 )))) { -uvc_trace (UVC_TRACE_CONTROL ,"Control " -UVC_GUID_FORMAT "/%u flags don't match " -"supported operations.\n" , -UVC_GUID_ARGS (info->entity), info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u flags don't match supported operations.\n" , + info->entity, info->selector);return ; } } ctrl->info = info; ctrl->data =kmalloc (ctrl->info->size *UVC_CTRL_NDATA ,GFP_KERNEL ); -uvc_trace (UVC_TRACE_CONTROL ,"Added control " UVC_GUID_FORMAT "/%u " -"to device %s entity %u\n" ,UVC_GUID_ARGS (ctrl->info->entity), - ctrl->info->selector, dev->udev->devpath, entity->id); +uvc_trace (UVC_TRACE_CONTROL , +"Added control %pUr/%u to device %s entity %u\n" , + ctrl->info->entity, ctrl->info->selector, + dev->udev->devpath, entity->id); }/*
@@ -1293,17 +1290,16 @@ int uvc_ctrl_add_info(struct uvc_control_info *info)continue ;if (ctrl->selector == info->selector) { -uvc_trace (UVC_TRACE_CONTROL ,"Control " -UVC_GUID_FORMAT "/%u is already defined.\n" , -UVC_GUID_ARGS (info->entity), info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u is already defined.\n" , + info->entity, info->selector); ret = -EEXIST ; goto end; }if (ctrl->index == info->index) { -uvc_trace (UVC_TRACE_CONTROL ,"Control " -UVC_GUID_FORMAT "/%u would overwrite index " -"%d.\n" ,UVC_GUID_ARGS (info->entity), - info->selector, info->index); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u would overwrite index %d.\n" , + info->entity, info->selector, info->index); ret = -EEXIST ; goto end; }
@@ -1344,10 +1340,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping)continue ;if (info->size *8 < mapping->size + mapping->offset) { -uvc_trace (UVC_TRACE_CONTROL ,"Mapping '%s' would " -"overflow control " UVC_GUID_FORMAT "/%u\n" , - mapping->name,UVC_GUID_ARGS (info->entity), - info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Mapping '%s' would overflow control %pUr/%u\n" , + mapping->name, info->entity, info->selector); ret = -EOVERFLOW ; goto end; }
@@ -1366,9 +1361,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping) mapping->ctrl = info;list_add_tail (&mapping->list, &info->mappings); -uvc_trace (UVC_TRACE_CONTROL ,"Adding mapping %s to control " -UVC_GUID_FORMAT "/%u.\n" , mapping->name, -UVC_GUID_ARGS (info->entity), info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Adding mapping %s to control %pUr/%u.\n" , + mapping->name, info->entity, info->selector); ret =0 ;break ;
drivers/media/video/uvc/uvc_driver.c +3 -4
@@ -328,11 +328,10 @@ static int uvc_parse_format(struct uvc_device *dev, sizeof format->name); format->fcc = fmtdesc->fcc; }else { -uvc_printk (KERN_INFO ,"Unknown video format " -UVC_GUID_FORMAT "\n" , -UVC_GUID_ARGS (&buffer[5 ])); +uvc_printk (KERN_INFO ,"Unknown video format %pUr\n" , + &buffer[5 ]);snprintf (format->name,sizeof format->name, -UVC_GUID_FORMAT ,UVC_GUID_ARGS (&buffer[5 ])); +"%pUr" , &Buffer[5 ]); format->fcc =0 ; }
drivers/media/video/uvc/uvcvideo.h +0 -10
@@ -555,16 +555,6 @@ extern unsigned int uvc_trace_param; #define uvc_printk(level, msg...) \ printk(level "uvcvideo: " msg) -#define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \ - "%02x%02x%02x%02x%02x%02x" -#define UVC_GUID_ARGS (guid) \ - (guid)[3], (guid)[2], (guid)[1], (guid)[0], \ - (guid)[5], (guid)[4], \ - (guid)[7], (guid)[6], \ - (guid)[8], (guid)[9], \ - (guid)[10], (guid)[11], (guid)[12], \ - (guid)[13], (guid)[14], (guid)[15] -/* -------------------------------------------------------------------------- * Internal functions. */
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 3/9 random.c: Use %pU to print UUIDs
In reply to Joe Perches--- drivers/char/random.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/char/random.c +3 -7
@@ -1245,12 +1245,8 @@ static int proc_do_uuid(ctl_table *table, int write,if (uuid[8 ] ==0 )generate_random_uuid (uuid); -sprintf (buf,"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" -"%02x%02x%02x%02x%02x%02x" , - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], - uuid[4 ], uuid[5 ], uuid[6 ], uuid[7 ], - uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], - uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ]); +sprintf (buf,"%pU" , uuid); + fake_table.data = buf; fake_table.maxlen =sizeof (buf);
@@ -1350,7 +1346,7 @@ ctl_table random_table[] = {/******************************************************************** * -* Random funtions for networking +* Random functions for networking * ********************************************************************/
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 2/9 efi.h: Use %pUr to print UUIDs
In reply to Joe Perches--- include/linux/efi.h | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
include/linux/efi.h +1 -5
@@ -280,11 +280,7 @@ efi_guidcmp (efi_guid_t left, efi_guid_t right)static inline char *efi_guid_unparse (efi_guid_t *guid,char *out) { -sprintf (out,"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" , - guid->b[3 ], guid->b[2 ], guid->b[1 ], guid->b[0 ], - guid->b[5 ], guid->b[4 ], guid->b[7 ], guid->b[6 ], - guid->b[8 ], guid->b[9 ], guid->b[10 ], guid->b[11 ], - guid->b[12 ], guid->b[13 ], guid->b[14 ], guid->b[15 ]); +sprintf (out,"%pUr" , guid->b);return out; }
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 8/9 fs/ubifs: Use %pUX to print UUIDs
In reply to Joe Perches--- fs/ubifs/debug.c | 9 ++------- fs/ubifs/super.c | 7 +------ 2 files changed, 3 insertions(+), 13 deletions(-)
fs/ubifs/debug.c +2 -7
@@ -350,13 +350,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) le32_to_cpu(sup->fmt_version));printk (KERN_DEBUG "\ttime_gran %u\n" ,le32_to_cpu (sup->time_gran)); -printk (KERN_DEBUG "\tUUID %02X%02X%02X%02X-%02X%02X" -"-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n" , - sup->uuid[0 ], sup->uuid[1 ], sup->uuid[2 ], sup->uuid[3 ], - sup->uuid[4 ], sup->uuid[5 ], sup->uuid[6 ], sup->uuid[7 ], - sup->uuid[8 ], sup->uuid[9 ], sup->uuid[10 ], sup->uuid[11 ], - sup->uuid[12 ], sup->uuid[13 ], sup->uuid[14 ], - sup->uuid[15 ]); +printk (KERN_DEBUG "\tUUID %pUX\n" , + sup->uuid);break ; }case UBIFS_MST_NODE :
fs/ubifs/super.c +1 -6
@@ -1393,12 +1393,7 @@ static int mount_ubifs(struct ubifs_info *c) c->leb_size, c->leb_size >> 10);dbg_msg ("data journal heads: %d" , c->jhead_cnt -NONDATA_JHEADS_CNT ); -dbg_msg ("UUID: %02X%02X%02X%02X-%02X%02X" -"-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X" , - c->uuid[0 ], c->uuid[1 ], c->uuid[2 ], c->uuid[3 ], - c->uuid[4 ], c->uuid[5 ], c->uuid[6 ], c->uuid[7 ], - c->uuid[8 ], c->uuid[9 ], c->uuid[10 ], c->uuid[11 ], - c->uuid[12 ], c->uuid[13 ], c->uuid[14 ], c->uuid[15 ]); +dbg_msg ("UUID: %pUX" , c->uuid);dbg_msg ("big_lpt %d" , c->big_lpt);dbg_msg ("log LEBs: %d (%d - %d)" , c->log_lebs,UBIFS_LOG_LNUM , c->log_last);
Signature · 1 line
1.6.3.1.10.g659a0.dirty
PATCH 4/9 drivers/firmware/dmi_scan.c: Use %pUX to print UUIDs
In reply to Joe Perches--- drivers/firmware/dmi_scan.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/firmware/dmi_scan.c +1 -4
@@ -169,10 +169,7 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int indeif (!s)return ; -sprintf (s, -"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X" , - d[0 ], d[1 ], d[2 ], d[3 ], d[4 ], d[5 ], d[6 ], d[7 ], - d[8 ], d[9 ], d[10 ], d[11 ], d[12 ], d[13 ], d[14 ], d[15 ]); +sprintf (s,"%pUX" , d); dmi_ident[slot] = s; }
Signature · 1 line
1.6.3.1.10.g659a0.dirty
Hi, Joe,
Thanks for the patch. I think that is a good idea.
For your patch. I think you need a changelog for each patch.
It seems that the binary representation of UUID can be little-endian (used by most kernel components) or big-endian (defined by RFC4122, used in network?). Maybe we should consider about that.
In fact, I find there are many different UUID/GUID definitions in kernel, such as that in efi, many file systems, some drivers, etc. It seems that every kernel components need UUID/GUID has its own definition, so I think we should unify all the UUID/GUID definitions in kernel too. The file attached is a draft unified UUID/GUID definition, with byte-order issue in mind.
Any comment?
Best Regards,
Huang Ying
From: Huang Ying <[email protected]>
Date: Fri, 7 Aug 2009 15:03:15 +0800
Subject: [PATCH] Unified UUID/GUID definition
There are many different UUID/GUID definitions in kernel, such as that in efi, many file systems, some drivers, etc. Every kernel components need UUID/GUID has its own definition. This patch provides a unified definition for UUID/GUID.
The binary representation of UUID/GUID can be little-endian (used by EFI, etc) or big-endian (defined by RFC4122), so both is defined.
--- include/linux/uuid.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/Makefile | 2 - lib/uuid.c | 33 ++++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 include/linux/uuid.h create mode 100644 lib/uuid.c
include/linux/uuid.h new file +101 -0
@@ -0,0 +1,101 @@ +/* +* Unified UUID/GUID definition +* +* Copyright (C) 2009, Intel Corp. +* Huang Ying <[email protected]> +* +* This file is released under the GPLv2. +*/ + +#ifndef _LINUX_UUID_H_ +#define _LINUX_UUID_H_ + +#include <linux/types.h> +#include <linux/string.h> + +typedef struct { +u8 b[16 ]; +}luuid_t ; + +typedef struct { +u8 b[16 ]; +}buuid_t ; + +#define LUUID (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ +((luuid_t) \ +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ + (b) & 0xff, ((b) >> 8) & 0xff, \ + (c) & 0xff, ((c) >> 8) & 0xff, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + +#define BUUID (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ +((luuid_t) \ +{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \ + ((b) >> 8) & 0xff, (b) & 0xff, \ + ((c) >> 8) & 0xff, (c) & 0xff, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + +#define NULL_UUID \ + LUUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00) + +static inline int luuid_cmp (luuid_t g1,luuid_t g2) +{ +return memcmp (&g1, &g2,sizeof (luuid_t)); +} + +static inline int buuid_cmp (buuid_t g1,buuid_t g2) +{ +return memcmp (&g1, &g2,sizeof (buuid_t)); +} + +static inline char *luuid_to_str (char *str,const luuid_t *g) +{ +sprintf (str,"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" +"%02x%02x%02x%02x%02x%02x" , + g->b[3 ], g->b[2 ], g->b[1 ], g->b[0 ], + g->b[5 ], g->b[4 ], g->b[7 ], g->b[6 ], + g->b[8 ], g->b[9 ], g->b[10 ], g->b[11 ], + g->b[12 ], g->b[13 ], g->b[14 ], g->b[15 ]); +return str; +} + +static inline char *buuid_to_str (char *str,const buuid_t *g) +{ +sprintf (str,"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" +"%02x%02x%02x%02x%02x%02x" , + g->b[0 ], g->b[1 ], g->b[2 ], g->b[3 ], + g->b[4 ], g->b[5 ], g->b[6 ], g->b[7 ], + g->b[8 ], g->b[9 ], g->b[10 ], g->b[11 ], + g->b[12 ], g->b[13 ], g->b[14 ], g->b[15 ]); +return str; +} + +static inline void luuid_to_buuid (buuid_t *bg,const luuid_t *lg) +{ + bg->b[0 ] = lg->b[3 ]; + bg->b[1 ] = lg->b[2 ]; + bg->b[2 ] = lg->b[1 ]; + bg->b[3 ] = lg->b[0 ]; + bg->b[4 ] = lg->b[5 ]; + bg->b[5 ] = lg->b[4 ]; + bg->b[6 ] = lg->b[7 ]; + bg->b[7 ] = lg->b[6 ]; +} + +static inline void buuid_to_luuid (luuid_t *lg,const buuid_t *bg) +{ + lg->b[0 ] = bg->b[3 ]; + lg->b[1 ] = bg->b[2 ]; + lg->b[2 ] = bg->b[1 ]; + lg->b[3 ] = bg->b[0 ]; + lg->b[4 ] = bg->b[5 ]; + lg->b[5 ] = bg->b[4 ]; + lg->b[6 ] = bg->b[7 ]; + lg->b[7 ] = bg->b[6 ]; +} + +extern void luuid_gen (luuid_t *g); +extern void buuid_gen (buuid_t *g); + +#endif
lib/Makefile +1 -1
@@ -21,7 +21,7 @@ lib-y += kobject.o kref.o klist.o obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ - string_helpers.o gcd.o + string_helpers.o gcd.o uuid.o ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG
lib/uuid.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Unified UUID/GUID definition +* +* Copyright (C) 2009, Intel Corp. +* Huang Ying <[email protected]> +* +* This file is released under the GPLv2. +*/ + +#include <linux/kernel.h> +#include <linux/uuid.h> +#include <linux/random.h> + +static void uuid_gen_common (u8 b[16 ]) +{ +get_random_bytes (b,16 ); +/* reversion 0b10 */ + b[8 ] = (b[8 ] &0x3F ) |0x80 ; +} + +void luuid_gen (luuid_t *lg) +{ +uuid_gen_common (lg->b); +/* version 4 : random generation */ + lg->b[7 ] = (lg->b[7 ] &0x0F ) |0x40 ; +} + +void buuid_gen (buuid_t *bg) +{ +uuid_gen_common (bg->b); +/* version 4 : random generation */ + bg->b[6 ] = (bg->b[6 ] &0x0F ) |0x40 ; +}
Re: [PATCH 7/9] fs/gfs2/sys.c: Use %pUX to print UUIDs
In reply to Joe PerchesHi,
Provided this gives identical output and people are happy with the general concept, then:
Looks like a nice cleanup,
Steve.
Quoted 39 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- fs/gfs2/sys.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-)fs/gfs2/sys.c +3
-13@@ -85,11 +85,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf) buf[0 ] ='\0' ;if (!gfs2_uuid_valid (uuid))return 0 ; -return snprintf (buf,PAGE_SIZE ,"%02X%02X%02X%02X-%02X%02X-" -"%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n" , - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], uuid[5 ], - uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], uuid[10 ], uuid[11 ], - uuid[12 ], uuid[13 ], uuid[14 ], uuid[15 ]); +return snprintf (buf,PAGE_SIZE ,"%pUX\n" , uuid); }static ssize_t freeze_show (struct gfs2_sbd *sdp,char *buf)@@ -573,14 +569,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,add_uevent_var (env,"LOCKPROTO=%s" , sdp->sd_proto_name);if (!sdp->sd_args.ar_spectator)add_uevent_var (env,"JOURNALID=%u" , sdp->sd_lockstruct.ls_jid); -if (gfs2_uuid_valid (uuid)) { -add_uevent_var (env,"UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" -"%02X%02X-%02X%02X%02X%02X%02X%02X" , - uuid[0 ], uuid[1 ], uuid[2 ], uuid[3 ], uuid[4 ], - uuid[5 ], uuid[6 ], uuid[7 ], uuid[8 ], uuid[9 ], - uuid[10 ], uuid[11 ], uuid[12 ], uuid[13 ], - uuid[14 ], uuid[15 ]); - } +if (gfs2_uuid_valid (uuid)) +add_uevent_var (env,"UUID=%pUX" , uuid);return 0 ; }
Re: [PATCH 8/9] fs/ubifs: Use %pUX to print UUIDs
In reply to Joe PerchesQuoted 5 lines · Joe Perches
Signed-off-by Joe Perches<[email protected]>--- fs/ubifs/debug.c | 9 ++------- fs/ubifs/super.c | 7 +------ 2 files changed, 3 insertions(+), 13 deletions(-)
Looks OK,
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Quoted 9 lines · On Tuesday 29 September 2009 07:57:32 Huang Ying wrote:
Hi, Joe,
Thanks for the patch. I think that is a good idea.
For your patch. I think you need a changelog for each patch.
It seems that the binary representation of UUID can be little-endian (used by most kernel components) or big-endian (defined by RFC4122, used in network?). Maybe we should consider about that.
I think that's what the 'r' option is supposed to handle. Maybe you could use 'b' and 'l' options instead, to specify the endianness explicitly.
Quoted 8 lines
In fact, I find there are many different UUID/GUID definitions in kernel, such as that in efi, many file systems, some drivers, etc. It seems that every kernel components need UUID/GUID has its own definition, so I think we should unify all the UUID/GUID definitions in kernel too. The file attached is a draft unified UUID/GUID definition, with byte-order issue in mind.
Any comment?
Not much, it would help if you could show where those functions would be used.
I would also use the 'le' and 'be' prefixes (as in le16, be32) instead of 'l' and 'b', making it leuuid and beuuid, or maybe uuid_le and uuid_be.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 6/9] drivers/media/video/uvc: Use %pUr to print UUIDs
In reply to Joe PerchesHi Joe,
thanks for the patch. A few comments below.
Quoted 12 lines · On Tuesday 29 September 2009 07:01:08 Joe Perches wrote:
Signed-off-by Joe Perches <[email protected]>--- drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------ drivers/media/video/uvc/uvc_driver.c | 7 +-- drivers/media/video/uvc/uvcvideo.h | 10 ----- 3 files changed, 35 insertions(+), 51 deletions(-)(quoted diff) +0
-0b/drivers/media/video/uvc/uvc_ctrl.c index c3225a5..2959e46 100644
drivers/media/video/uvc/uvc_ctrl.c int uvc_xu_ctrl_query(struct uvc_video_chain *chain, · line 1098
Quoted 8 lines
drivers/media/video/uvc/uvc_ctrl.c +2
-2@@ -1093,8 +1093,8 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,if (!found) {uvc_trace (UVC_TRACE_CONTROL , -"Control " UVC_GUID_FORMAT "/%u not found.\n" , -UVC_GUID_ARGS (entity->extension.guidExtensionCode), +"Control %pUr/%u not found.\n" , + entity->extension.guidExtensionCode, xctrl->selector);
Could you try to cut long statements in as few lines as possible ? This one would become
uvc_trace(UVC_TRACE_CONTROL, "Control %pUr/%u not found.\n", entity->extension.guidExtensionCode, xctrl->selector);
There are a few others that should be changed as well. If you prefer I can apply the patch through my tree (after the printk patch goes in of course) and handle that myself.
[snip]
drivers/media/video/uvc/uvc_ctrl.c static void uvc_ctrl_add_ctrl(struct uvc_device *dev, · line 1257
Quoted 10 lines
drivers/media/video/uvc/uvc_ctrl.c +0
-0flags = info->flags; if (((flags & UVC_CONTROL_GET_CUR) && !(inf & (1 << 0))) ||drivers/media/video/uvc/uvc_ctrl.c +3
-4((flags & UVC_CONTROL_SET_CUR) && !(inf & (1 << 1)))) { -uvc_trace (UVC_TRACE_CONTROL ,"Control " -UVC_GUID_FORMAT "/%u flags don't match " -"supported operations.\n" , -UVC_GUID_ARGS (info->entity), info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u flags don't match supported operations.\n" , + info->entity, info->selector);
This doesn't fit the 80 columns limit. Please run checkpatch.pl on your patches.
[snip]
Quoted 6 lines
(quoted diff) +0
-0b/drivers/media/video/uvc/uvc_driver.c index 8756be5..647d0a2 100644drivers/media/video/uvc/uvc_driver.c +0
-0@@ -328,11 +328,10 @@ static int uvc_parse_format(struct uvc_device *dev, sizeof format->name);
drivers/media/video/uvc/uvc_driver.c static int uvc_parse_format(struct uvc_device *dev, · line 334
Quoted 10 lines
drivers/media/video/uvc/uvc_driver.c +3
-4format->fcc = fmtdesc->fcc; }else { -uvc_printk (KERN_INFO ,"Unknown video format " -UVC_GUID_FORMAT "\n" , -UVC_GUID_ARGS (&buffer[5 ])); +uvc_printk (KERN_INFO ,"Unknown video format %pUr\n" , + &buffer[5 ]);snprintf (format->name,sizeof format->name, -UVC_GUID_FORMAT ,UVC_GUID_ARGS (&buffer[5 ])); +"%pUr" , &Buffer[5 ]);
Should be &buffer[5], not &Buffer[5]. You haven't compiled the patch, have you ? :-)
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 6 lines · Laurent Pinchart
Quoted 3 lines · On Tuesday 29 September 2009 07:57:32 Huang Ying wrote:
It seems that the binary representation of UUID can be little-endian (used by most kernel components) or big-endian (defined by RFC4122, used in network?). Maybe we should consider about that.
I think that's what the 'r' option is supposed to handle. Maybe you could use 'b' and 'l' options instead, to specify the endianness explicitly.
or %pUbe and $pUle.
I've no objections, whatever's clearer to most people.
Quoted 7 lines
Quoted 7 lines
In fact, I find there are many different UUID/GUID definitions in kernel, such as that in efi, many file systems, some drivers, etc. It seems that every kernel components need UUID/GUID has its own definition, so I think we should unify all the UUID/GUID definitions in kernel too. The file attached is a draft unified UUID/GUID definition, with byte-order issue in mind.
Quoted 6 lines
Quoted 1 line
Any comment?
Not much, it would help if you could show where those functions would be used.
I would also use the 'le' and 'be' prefixes (as in le16, be32) instead of 'l' and 'b', making it leuuid and beuuid, or maybe
uuid_leanduuid_be.
A reply might take awhile.
I believe Ying is on vacation for a week or so.
Here is the list that Ying sent me:
GUID in Linux kernel
arch/ia64/*.c: efi_guid_tarch/x86/kernel/efi.c: efi_guid_t
fs/partitions/efi.[ch]: efi_guid_tdrivers/firmware/efivars.c: efi_guid_t
fs/partitions/ldm.[ch]: u8 [16], ldm_parse_guid,
memcmp, memcpyfs/ntfs/layout.h: GUID
fs/cifs/cifs*.[ch]: u8 [16], memcpydrivers/platform/x86/*wmi.c: u8[16], wmi_parse_guid
drivers/media/video/uvc/uvc*.[ch]: u8[16], constants, format
(bin-»ascii),struct initialize(!!)drivers/net/usb/zaurus.c: u8[16]drivers/staging/hv/*.c: hv_guid initializing,drivers/char/ipmi/ipmi_msghandler.c: u8[16] show (sysfs)
Not standard uuid
fs/squashfs/*.[ch]: __le16include/linux/firewire.h: unsigned long long
drivers/firewire/*.[ch]:
drivers/ieee1394/*.[ch]:drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h: u8[24]
drivers/infiniband/*.[ch]: __be64
UUID in Linux kernel
arch/arm/*/sharpsl_param.[ch]: u8[16]
arch/ia64/*/perfmon.[ch]: pfm_uuid_t=u8[16] cmp, formatarch/ia64/sn/kernel/io_acpi_init.c: acpi_vendor_uuid initializingarch/x86/kernel/tboot.c: u8[16]
initializing,cmpinclude/linux/tboot.h:include/acpi/actbl1.h: u8[16]include/acpi/acpi/acrestyp.h acpi_uuid=struct {u8[16]}, acpi_vendor_uuid,u8[16] drivers/acpi/acpica/*.[ch] drivers/acpi/pci_root.c drivers/pnp/pnpacpi/*.[ch]include/linux/ext2_fs.h: u8[16]include/linux/ext3_fs.h:
fs/ext3/*.[ch]drivers/ext4/ext4.h:drivers/ext4/super.c:include/linux/nfsd/nfsfh.h: u8[16]fs/nfsd/*.cinclude/linux/wlp.h: wlp_uuid=struct{u8[16]}
drivers/uwb/wlp/*.[ch]include/linux/jbd2.h: u8[16]include/linux/jbd.h:include/linux/gfs2_ondisk.h: u8[16]
fs/gfs2/*.[ch]include/linux/nilfs2_fs.h: u8[16]
fs/jfs/*.[ch]: u8[16] access
component
fs/ubifs/*.[ch]: u8[16] generate!!!
fs/xfs/support/uuid.[ch]: uuid_t=struct{u8[16]}
fs/xfs/*.[ch]
fs/ocfs2/*.[ch]: u8[16]drivers/char/random.c: u8[16]generate_random_uuidinclude/linux/reiserfs_fs.h: u8[16]fs/reiserfs/objectid.c:
fs/btrfs/*.[ch]: u8[16]
fs/afs/*.[ch]: afs_uuid=struct{u32,u16,xxx}
unmarshall(!!!), generate (DEC ver1 mode)
drivers/md/md.[ch]: u8[16]generate(get_random_bytes) drivers/md/drivers.[ch]:
Not standard UUID
include/linux/dm-ioctl.h: u8[129]include/linux/dm-log-userspace.h:
drivers/md/dm-*.[ch]:
Re: [PATCH 6/9] drivers/media/video/uvc: Use %pUr to print UUIDs
In reply to Laurent PinchartQuoted 4 lines · Laurent Pinchart
Quoted 4 lines
drivers/media/video/uvc/uvc_ctrl.c +0
-1flags = info->flags;if (((flags &UVC_CONTROL_GET_CUR ) && !(inf & (1 <<0 ))) || ((flags &UVC_CONTROL_SET_CUR ) && !(inf & (1 <<1 )))) { - uvc_trace(UVC_TRACE_CONTROL, "Control "
Quoted 8 lines
drivers/media/video/uvc/uvc_ctrl.c static void uvc_ctrl_add_ctrl(struct uvc_device *dev, · line 1257
Quoted 6 lines
drivers/media/video/uvc/uvc_ctrl.c +3
-3-UVC_GUID_FORMAT "/%u flags don't match " -"supported operations.\n" , - UVC_GUID_ARGS(info->entity), info->selector); +uvc_trace (UVC_TRACE_CONTROL , +"Control %pUr/%u flags don't match supported operations.\n" , + info->entity, info->selector);This doesn't fit the 80 columns limit. Please run checkpatch.pl on your patches.
Intentional. Strings shouldn't be broken across lines unnecessarily.
Quoted 6 lines
drivers/media/video/uvc/uvc_driver.c static int uvc_parse_format(struct uvc_device *dev, · line 334
Quoted 3 lines
drivers/media/video/uvc/uvc_driver.c +1
-1snprintf (format->name,sizeof format->name, -UVC_GUID_FORMAT ,UVC_GUID_ARGS (&buffer[5 ])); +"%pUr" , &Buffer[5 ]);Should be &buffer[5], not &Buffer[5]. You haven't compiled the patch, have you ? :-)
Unintentional. Did compile allyesconfig.
cheers, Joe
Re: [PATCH 1/9] lib/vsprintf.c: Add %pU to print UUID/GUIDs
In reply to Joe PerchesQuoted 8 lines · Joe Perches
UUID/GUIDs are somewhat common in kernel source.
Standardize the printed style of UUID/GUIDs by using another extension to %p.
%pU: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUr: 04030201-0605-0807-090a-0b0c0d0e0f10
%pU[r]X:Use upper case hex
To me, it looks a bit strange to have the options after the `U', combined with the variable-length nature.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 1/9] lib/vsprintf.c: Add %pU to print UUID/GUIDs
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines
Standardize the printed style of UUID/GUIDs by using another extension to %p.
%pU: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUr: 04030201-0605-0807-090a-0b0c0d0e0f10
%pU[r]X:Use upper case hexTo me, it looks a bit strange to have the options after the `U', combined with the variable-length nature.
I think the whole %p<foo> mechanism is strange and takes a bit of getting used to.
You're free to suggest alternatives.
Keep in mind expansion for future different types and that <foo> must be alphanumeric chars only.
cheers, Joe
Re: [PATCH 1/9] lib/vsprintf.c: Add %pU to print UUID/GUIDs
Quoted 11 lines · Joe Perches
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines
Standardize the printed style of UUID/GUIDs by using another extension to %p.
%pU: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUr: 04030201-0605-0807-090a-0b0c0d0e0f10
%pU[r]X:Use upper case hexTo me, it looks a bit strange to have the options after the `U', combined with the variable-length nature.
Quoted 7 lines
I think the whole %p<foo> mechanism is strange and takes a bit of getting used to.
You're free to suggest alternatives.
Keep in mind expansion for future different types and that <foo> must be alphanumeric chars only.
`r' is reverse endianness?
So what about
%pUb: lower case big endian
%pUl: lower case little endian
%pUB: upper case big endian
%pUL: upper case little endian
?
That way it's fixed length, and easier to parse.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 1/9] lib/vsprintf.c: Add %pU to print UUID/GUIDs
Quoted 12 lines · Geert Uytterhoeven
Quoted 11 lines · Joe Perches
Quoted 7 lines · Geert Uytterhoeven
Quoted 5 lines
Standardize the printed style of UUID/GUIDs by using another extension to %p.
%pU: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUr: 04030201-0605-0807-090a-0b0c0d0e0f10
%pU[r]X:Use upper case hexTo me, it looks a bit strange to have the options after the `U', combined with the variable-length nature.
I think the whole %p<foo> mechanism is strange and takes a bit of getting used to.
You're free to suggest alternatives.
Quoted 7 lines
`r' is reverse endianness?
So what about
%pUb: lower case big endian
%pUl: lower case little endian
%pUB: upper case big endian
%pUL: upper case little endian
That way it's fixed length, and easier to parse.
Thanks Geert.
That's OK with me.
%pU now defaults to %pUb and I'll resubmit it later.
Anyone else?
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · On Tuesday 29 September 2009 07:57:32 Huang Ying wrote:
Hi, Joe,
Thanks for the patch. I think that is a good idea.
Quoted 8 lines
Quoted 5 lines
For your patch. I think you need a changelog for each patch.
It seems that the binary representation of UUID can be little-endian (used by most kernel components) or big-endian (defined by RFC4122, used in network?). Maybe we should consider about that.
I think that's what the 'r' option is supposed to handle. Maybe you could use 'b' and 'l' options instead, to specify the endianness explicitly.
Yes. Thanks for you reminding.
Quoted 7 lines
Quoted 7 lines
In fact, I find there are many different UUID/GUID definitions in kernel, such as that in efi, many file systems, some drivers, etc. It seems that every kernel components need UUID/GUID has its own definition, so I think we should unify all the UUID/GUID definitions in kernel too. The file attached is a draft unified UUID/GUID definition, with byte-order issue in mind.
Quoted 6 lines
Quoted 1 line
Any comment?
Not much, it would help if you could show where those functions would be used.
I would also use the 'le' and 'be' prefixes (as in le16, be32) instead of 'l' and 'b', making it leuuid and beuuid, or maybe
uuid_leanduuid_be.
Yes. It seems 'be' and 'le' is better than 'b' an 'l'.
Best Regards,
Huang Ying