more mtd-utils cleanup
Subsystems (3)
cover more mtd-utils cleanup
This series fixes several mtd-utils issues and takes care of a few things on the feature-removal schedule.
I think patch 9 ("mtdinfo: kill -m option") could use some review, as I am not the one who formed the original feature removal request.
Thanks,
Brian
Brian Norris (10):
mtd-tests: checkfs: fix size_t related warning
mtd-tests: io_paral: build error, "variable length strings"
mtd-utils: remove whitespace at end of lines
mtd-utils: update .gitignore files
mkfs.ubifs: use common.h
mtd-utils: add common version printing function
mtd-utils: switch more utils to unified versioning
mtd-utils: kill flash_info
mtdinfo: kill -m option
nanddump: remove unused variable
.gitignore | 5 ++ Makefile | 2 +- device_table.txt | 6 +- feature-removal-schedule.txt | 14 ------ flash_info.c | 67 ------------------------------ include/common.h | 6 +++ include/linux/jffs2.h | 2 +- jffs2dump.c | 2 +- lib/libfec.c | 14 +++--- mcast_image.h | 4 +- mkfs.jffs2.1 | 6 +- mkfs.jffs2.c | 6 +- mkfs.ubifs/hashtable/hashtable.c | 14 +++--- mkfs.ubifs/hashtable/hashtable.h | 30 +++++++------- mkfs.ubifs/hashtable/hashtable_itr.c | 12 +++--- mkfs.ubifs/hashtable/hashtable_itr.h | 12 +++--- mkfs.ubifs/hashtable/hashtable_private.h | 12 +++--- mkfs.ubifs/mkfs.ubifs.c | 12 ++---- nanddump.c | 3 +- nandtest.c | 16 ++++---- rbtree.c | 6 +- rbtree.h | 4 +- recv_image.c | 24 +++++----- serve_image.c | 30 +++++++------- tests/checkfs/.gitignore | 2 + tests/checkfs/README | 26 ++++++------ tests/checkfs/checkfs.c | 2 +- tests/fs-tests/integrity/.gitignore | 1 + tests/fs-tests/simple/.gitignore | 5 ++ tests/fs-tests/stress/atoms/.gitignore | 10 ++++ tests/fs-tests/utils/.gitignore | 2 + tests/jittertest/.gitignore | 2 + tests/jittertest/README | 18 ++++---- tests/jittertest/filljffs2.sh | 2 +- tests/ubi-tests/io_paral.c | 2 +- ubi-utils/dictionary.c | 6 +- ubi-utils/libiniparser.c | 8 ++-- ubi-utils/mtdinfo.c | 30 ++++---------- ubi-utils/ubiattach.c | 5 +- ubi-utils/ubicrc32.c | 5 +- ubi-utils/ubidetach.c | 5 +- ubi-utils/ubiformat.c | 5 +- ubi-utils/ubimkvol.c | 5 +- ubi-utils/ubinfo.c | 5 +- ubi-utils/ubinize.c | 5 +- ubi-utils/ubirename.c | 1 - ubi-utils/ubirmvol.c | 5 +- ubi-utils/ubirsvol.c | 5 +- ubi-utils/ubiupdatevol.c | 5 +- 49 files changed, 199 insertions(+), 277 deletions(-) delete mode 100644 flash_info.c create mode 100644 tests/checkfs/.gitignore create mode 100644 tests/fs-tests/integrity/.gitignore create mode 100644 tests/fs-tests/simple/.gitignore create mode 100644 tests/fs-tests/stress/atoms/.gitignore create mode 100644 tests/fs-tests/utils/.gitignore create mode 100644 tests/jittertest/.gitignore
PATCH 1/10 mtd-tests: checkfs: fix size_t related warning
Depending on your compiler, size_t may or may not be long unsigned int. Use printf's %zu format to clarify.
Warning message:
checkfs.c:524:28: warning: format '%lu' expects type 'long unsigned int', but argument 2 has type 'unsigned int'
--- tests/checkfs/checkfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tests/checkfs/checkfs.c +1 -1
@@ -520,7 +520,7 @@ void processCmdLine(int argc, char **argv) FileSizeMax = (float )atoi (argv[++cnt]);if (FileSizeMax > (MAX_INTS_ALLOW *sizeof (int ))) { -printf ("Max file size allowed is %lu.\n" , +printf ("Max file size allowed is %zu.\n" ,MAX_INTS_ALLOW *sizeof (int ));exit (0 ); }
Signature · 1 line
1.7.0.4
PATCH 2/10 mtd-tests: io_paral: build error, "variable length strings"
In reply to Brian NorrisSome compilers will complain about use of strlen() within a static array size declaration. For this type of string, "sizeof() - 1" is equivalent and prevents the build error.
Error:
io_paral.c:48:13: error: variably modified 'vol_nodes' at file scope
--- tests/ubi-tests/io_paral.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tests/ubi-tests/io_paral.c +1 -1
@@ -45,7 +45,7 @@ static int vol_size;static struct ubi_mkvol_request reqests[THREADS_NUM +1 ];static char vol_name[THREADS_NUM +1 ][100 ]; -static char vol_nodes[THREADS_NUM +1 ][strlen (UBI_VOLUME_PATTERN ) +100 ]; +static char vol_nodes[THREADS_NUM +1 ][sizeof (UBI_VOLUME_PATTERN ) +99 ];static unsigned char *wbufs[THREADS_NUM +1 ];static unsigned char *rbufs[THREADS_NUM +1 ];
Signature · 1 line
1.7.0.4
PATCH 3/10 mtd-utils: remove whitespace at end of lines
In reply to Brian Norris--- device_table.txt | 6 +++--- include/linux/jffs2.h | 2 +- lib/libfec.c | 14 +++++++------- mcast_image.h | 4 ++-- mkfs.jffs2.1 | 6 +++--- mkfs.jffs2.c | 6 +++--- mkfs.ubifs/hashtable/hashtable.c | 14 +++++++------- mkfs.ubifs/hashtable/hashtable.h | 30 +++++++++++++++--------------- mkfs.ubifs/hashtable/hashtable_itr.c | 12 ++++++------ mkfs.ubifs/hashtable/hashtable_itr.h | 12 ++++++------ mkfs.ubifs/hashtable/hashtable_private.h | 12 ++++++------ nandtest.c | 16 ++++++++-------- rbtree.c | 6 +++--- rbtree.h | 4 ++-- recv_image.c | 24 ++++++++++++------------ serve_image.c | 30 +++++++++++++++--------------- tests/checkfs/README | 26 +++++++++++++------------- tests/jittertest/README | 18 +++++++++--------- tests/jittertest/filljffs2.sh | 2 +- ubi-utils/dictionary.c | 6 +++--- ubi-utils/libiniparser.c | 8 ++++---- 21 files changed, 129 insertions(+), 129 deletions(-)
device_table.txt +3 -3
@@ -5,10 +5,10 @@ # /sbin/foobar f 2755 0 0 - - - - - # and (assuming the file /sbin/foobar exists) it will be made setuid # root (regardless of what its permissions are on the host filesystem. -# +# # Device table entries take the form of: # <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> -# where name is the file name, type can be one of: +# where name is the file name, type can be one of: # f A regular file # d Directory # c Character special device file
@@ -19,7 +19,7 @@ # file. # When building a target filesystem, it is desirable to not have to -# become root and then run 'mknod' a thousand times. Using a device +# become root and then run 'mknod' a thousand times. Using a device # table you can create device nodes and directories "on the fly". # Furthermore, you can use a single table entry to create a many device # minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15]
include/linux/jffs2.h +1 -1
@@ -15,7 +15,7 @@#ifndef __LINUX_JFFS2_H__#define __LINUX_JFFS2_H__ -/* You must include something which defines the C99 uintXX_t types. +/* You must include something which defines the C99 uintXX_t types. We don't do it from here because this file is used in too many different environments. */
lib/libfec.c +7 -7
@@ -79,7 +79,7 @@ typedef unsigned short u_short ;if (t1 < t) t =256000000 + t1 - t ; \else t = t1 - t ; \ if (t == 0) t = 1 ;} - +u_long ticks[10 ];/* vars for timekeeping */ #else #define DEB (x)
@@ -200,7 +200,7 @@ static inline gf gf_mul(x,y) {if ( (x) ==0 || (y)==0 )return 0 ; - +return gf_exp[gf_log[x] + gf_log[y] ] ; }#define init_mul_table ()
@@ -315,7 +315,7 @@ generate_gf(void)* unrolled 16 times, a good value for 486 and pentium-class machines. * The case c=0 is also optimized, whereas c=1 is not. These * calls are unfrequent in my typical apps so I did not bother. -* +* * Note that gcc on */ #define addmul (dst, src, c, sz) \
@@ -452,7 +452,7 @@ invert_mat(gf *src, int k) } }else if (ipiv[ix] >1 ) {fprintf (stderr,"singular matrix\n" ); - goto fail ; + goto fail ; } } }
@@ -562,7 +562,7 @@ invert_vdm(gf *src, int k) b =NEW_GF_MATRIX (1 , k); p =NEW_GF_MATRIX (1 , k); - +for ( j=1 , i =0 ; i < k ; i++, j+=k ) { c[i] =0 ; p[i] = src[j] ;/* p[i] */
@@ -807,7 +807,7 @@ build_decode_matrix(struct fec_parms *code, int index[]) } else#endif if (index[i] < code->n ) -memcpy (p, &(code->enc_matrix[index[i]*k]), k*sizeof (gf) ); +memcpy (p, &(code->enc_matrix[index[i]*k]), k*sizeof (gf) );else {fprintf (stderr,"decode: invalid index %d (max %d)\n" , index[i], code->n -1 );
@@ -838,7 +838,7 @@ build_decode_matrix(struct fec_parms *code, int index[])int fec_decode (struct fec_parms *code,gf *pkt[],int index[],int sz) { -gf *m_dec ; +gf *m_dec ;gf **new_pkt ;int row, col , k = code->k ;
mcast_image.h +2 -2
@@ -24,7 +24,7 @@ struct image_pkt {struct fec_parms ;/* k - number of actual data packets -* n - total number of packets including data and redundant packets +* n - total number of packets including data and redundant packets * (actual packet size isn't relevant here) */ struct fec_parms *fec_new (int k,int n);void fec_free (struct fec_parms *p);
@@ -45,7 +45,7 @@ void fec_encode_linear(struct fec_parms *code, unsigned char *src,/* data - array of (k) pointers to data packets, in arbitrary order (see i) * i - indices of (data) packets * sz - data packet size -* +* * Will never fail as long as you give it (k) individual data packets. * Will re-order the (data) pointers but not the indices -- data packets * are ordered on return.
mkfs.jffs2.1 +3 -3
@@ -104,7 +104,7 @@ or the present directory, if the .B -r option is not specified. -Each block of the files to be placed into the file system image +Each block of the files to be placed into the file system image are compressed using one of the avaiable compressors depending on the selected compression mode.
@@ -196,8 +196,8 @@ Enables xattr, stuff only SELinux Labels into jffs2 image file. Enable xattr, stuff only POSIX ACL entries into jffs2 image file. .TP .B -m, --compression-mode=MODE -Set the default compression mode. The default mode is -.B priority +Set the default compression mode. The default mode is +.B priority which tries the compressors in a predefinied order and chooses the first successful one. The alternatives are: .B none
mkfs.jffs2.c +3 -3
@@ -123,11 +123,11 @@ uint32_t find_hardlink(struct filesystem_entry *e) f = rb_entry(parent, struct filesystem_entry, hardlink_rb);if ((f->sb.st_dev < e->sb.st_dev) || - (f->sb.st_dev == e->sb.st_dev && + (f->sb.st_dev == e->sb.st_dev && f->sb.st_ino < e->sb.st_ino)) n = &parent->rb_left;else if ((f->sb.st_dev > e->sb.st_dev) || - (f->sb.st_dev == e->sb.st_dev && + (f->sb.st_dev == e->sb.st_dev && f->sb.st_ino > e->sb.st_ino)) { n = &parent->rb_right; }else
@@ -264,7 +264,7 @@ static struct filesystem_entry *add_host_filesystem_entry(const char *name, tmp =xstrdup (name); entry->path =xstrdup (dirname (tmp));free (tmp); - + entry->sb.st_ino = sb.st_ino; entry->sb.st_dev = sb.st_dev; entry->sb.st_nlink = sb.st_nlink;
mkfs.ubifs/hashtable/hashtable.c +7 -7
@@ -100,7 +100,7 @@ hashtable_expand(struct hashtable *h) h->table = newtable; }/* Plan B: realloc instead */ -else +else { newtable = (struct entry **)realloc (h->table, newsize *sizeof (struct entry *));
@@ -246,23 +246,23 @@ hashtable_destroy(struct hashtable *h, int free_values)/* * Copyright (c) 2002, Christopher Clark * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: -* +* * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. -* +* * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. -* +* * * Neither the name of the original author; nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. -* -* +* +* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
mkfs.ubifs/hashtable/hashtable.h +15 -15
@@ -19,7 +19,7 @@ struct hashtable;* v = (struct some_value *) malloc(sizeof(struct some_value)); * * (initialise k and v to suitable values) -* +* * if (! hashtable_insert(h,k,v) ) * { exit(-1); } *
@@ -33,7 +33,7 @@ struct hashtable;/* Macros may be used to define type-safe(r) hashtable access functions, with * methods specialized to take known key and value types as parameters. -* +* * Example: * * Insert this at the start of your file:
@@ -63,7 +63,7 @@ struct hashtable;/***************************************************************************** * create_hashtable -+ * @name create_hashtable * @param minsize minimum initial size of hashtable * @param hashfunction function for hashing keys
@@ -78,7 +78,7 @@ create_hashtable(unsigned int minsize,/***************************************************************************** * hashtable_insert -+ * @name hashtable_insert * @param h the hashtable to insert into * @param k the key - hashtable claims ownership and will free on removal
@@ -95,7 +95,7 @@ create_hashtable(unsigned int minsize,* If in doubt, remove before insert. */ -int +int hashtable_insert (struct hashtable *h,void *k,void *v);#define DEFINE_HASHTABLE_INSERT (fnname, keytype, valuetype) \
@@ -106,7 +106,7 @@ int fnname (struct hashtable *h, keytype *k, valuetype *v) \/***************************************************************************** * hashtable_search -+ * @name hashtable_search * @param h the hashtable to search * @param k the key to search for - does not claim ownership
@@ -124,7 +124,7 @@ valuetype * fnname (struct hashtable *h, keytype *k) \/***************************************************************************** * hashtable_remove -+ * @name hashtable_remove * @param h the hashtable to remove the item from * @param k the key to search for - does not claim ownership
@@ -143,7 +143,7 @@ valuetype * fnname (struct hashtable *h, keytype *k) \/***************************************************************************** * hashtable_count -+ * @name hashtable_count * @param h the hashtable * @return the number of items stored in the hashtable
@@ -154,7 +154,7 @@ hashtable_count(struct hashtable *h);/***************************************************************************** * hashtable_destroy -+ * @name hashtable_destroy * @param h the hashtable * @param free_values whether to call 'free' on the remaining values
@@ -168,23 +168,23 @@ hashtable_destroy(struct hashtable *h, int free_values);/* * Copyright (c) 2002, Christopher Clark * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: -* +* * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. -* +* * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. -* +* * * Neither the name of the original author; nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. -* -* +* +* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
mkfs.ubifs/hashtable/hashtable_itr.c +6 -6
@@ -157,23 +157,23 @@ hashtable_iterator_search(struct hashtable_itr *itr,/* * Copyright (c) 2002, 2004, Christopher Clark * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: -* +* * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. -* +* * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. -* +* * * Neither the name of the original author; nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. -* -* +* +* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
mkfs.ubifs/hashtable/hashtable_itr.h +6 -6
@@ -81,23 +81,23 @@ int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \/* * Copyright (c) 2002, 2004, Christopher Clark * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: -* +* * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. -* +* * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. -* +* * * Neither the name of the original author; nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. -* -* +* +* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
mkfs.ubifs/hashtable/hashtable_private.h +6 -6
@@ -54,23 +54,23 @@ indexFor(unsigned int tablelength, unsigned int hashvalue)/* * Copyright (c) 2002, Christopher Clark * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: -* +* * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. -* +* * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. -* +* * * Neither the name of the original author; nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. -* -* +* +* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nandtest.c +8 -8
@@ -79,7 +79,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)printf ("\r%08x: reading..." , (unsigned )ofs);fflush (stdout); - + len =pread (fd, rbuf, meminfo.erasesize, ofs);if (len < meminfo.erasesize) {printf ("\n" );
@@ -89,7 +89,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)perror ("read" );exit (1 ); } - +if (ioctl (fd,ECCGETSTATS , &newstats)) {printf ("\n" );perror ("ECCGETSTATS" );
@@ -184,7 +184,7 @@ int main(int argc, char **argv)case 'l' : length =strtol (optarg,NULL ,0 );break ; - + } }if (argc - optind !=1 )
@@ -195,7 +195,7 @@ int main(int argc, char **argv)perror ("open" );exit (1 ); } - +if (ioctl (fd,MEMGETINFO , &meminfo)) {perror ("MEMGETINFO" );close (fd);
@@ -206,20 +206,20 @@ int main(int argc, char **argv) length = meminfo.size;if (offset % meminfo.erasesize) { -fprintf (stderr,"Offset %x not multiple of erase size %x\n" , +fprintf (stderr,"Offset %x not multiple of erase size %x\n" , offset, meminfo.erasesize);exit (1 ); }if (length % meminfo.erasesize) { -fprintf (stderr,"Length %x not multiple of erase size %x\n" , +fprintf (stderr,"Length %x not multiple of erase size %x\n" , length, meminfo.erasesize);exit (1 ); }if (length + offset > meminfo.size) { -fprintf (stderr,"Length %x + offset %x exceeds device size %x\n" , +fprintf (stderr,"Length %x + offset %x exceeds device size %x\n" , length, offset, meminfo.size);exit (1 ); - } + } wbuf =malloc (meminfo.erasesize *3 );if (!wbuf) {
rbtree.c +3 -3
@@ -2,7 +2,7 @@ Red Black Trees (C) 1999 Andrea Arcangeli <[email protected]> (C) 2002 David Woodhouse <[email protected]> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
@@ -324,7 +324,7 @@ struct rb_node *rb_next(struct rb_node *node)/* If we have a right-hand child, go down and then left as far as we can. */ if (node->rb_right) { - node = node->rb_right; + node = node->rb_right;while (node->rb_left) node=node->rb_left;return node;
@@ -352,7 +352,7 @@ struct rb_node *rb_prev(struct rb_node *node)/* If we have a left-hand child, go down and then right as far as we can. */ if (node->rb_left) { - node = node->rb_left; + node = node->rb_left;while (node->rb_right) node=node->rb_right;return node;
rbtree.h +2 -2
@@ -1,7 +1,7 @@/* Red Black Trees (C) 1999 Andrea Arcangeli <[email protected]> -+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
@@ -156,7 +156,7 @@ extern struct rb_node *rb_first(struct rb_root *);extern struct rb_node *rb_last (struct rb_root *);/* Fast replacement of a single node without remove/rebalance/add/rebalance */ -extern void rb_replace_node (struct rb_node *victim,struct rb_node *new, +extern void rb_replace_node (struct rb_node *victim,struct rb_node *new,struct rb_root *root); static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
recv_image.c +12 -12
@@ -111,7 +111,7 @@ int main(int argc, char **argv)memset (&hints,0 ,sizeof (hints)); hints.ai_flags =AI_ADDRCONFIG ; hints.ai_socktype =SOCK_DGRAM ; - + ret =getaddrinfo (argv[1 ], argv[2 ], &hints, &ai);if (ret) {fprintf (stderr,"getaddrinfo: %s\n" ,gai_strerror (ret));
@@ -131,18 +131,18 @@ int main(int argc, char **argv) rq.imr_multiaddr = ((struct sockaddr_in *)runp->ai_addr)->sin_addr; rq.imr_interface.s_addr =INADDR_ANY ;if (setsockopt (sock,IPPROTO_IP ,IP_ADD_MEMBERSHIP , &rq,sizeof (rq))) { -perror ("IP_ADD_MEMBERSHIP" ); +perror ("IP_ADD_MEMBERSHIP" );close (sock);continue ; } - + }else if (runp->ai_family ==AF_INET6 && ((struct sockaddr_in6 *)runp->ai_addr)->sin6_addr.s6_addr[0 ] ==0xff ) {struct ipv6_mreq rq; rq.ipv6mr_multiaddr = ((struct sockaddr_in6 *)runp->ai_addr)->sin6_addr; rq.ipv6mr_interface =0 ;if (setsockopt (sock,IPPROTO_IPV6 ,IPV6_ADD_MEMBERSHIP , &rq,sizeof (rq))) { -perror ("IPV6_ADD_MEMBERSHIP" ); +perror ("IPV6_ADD_MEMBERSHIP" );close (sock);continue ; }
@@ -254,7 +254,7 @@ int main(int argc, char **argv)continue ; } pkt_again: - eraseblocks[block_nr].pkt_indices[eraseblocks[block_nr].nr_pkts++] = + eraseblocks[block_nr].pkt_indices[eraseblocks[block_nr].nr_pkts++] =ntohs (thispkt.hdr.pkt_nr); total_pkts++;if (!(total_pkts %50 ) || total_pkts == pkts_per_block * nr_blocks) {
@@ -290,7 +290,7 @@ int main(int argc, char **argv) thispkt.data, fits); wrotelen =pwrite (flfd, eraseblocks[block_nr].wbuf,WBUF_SIZE , eraseblocks[block_nr].flash_offset); - +if (wrotelen <WBUF_SIZE || (block_nr ==5 && eraseblocks[block_nr].nr_pkts ==5 && !faked)) { faked =1 ;if (wrotelen <0 )
@@ -308,7 +308,7 @@ int main(int argc, char **argv) ~(meminfo.erasesize -1 ); erase.length = meminfo.erasesize; -printf ("Will erase at %08x len %08x (bad write was at %08x)\n" , +printf ("Will erase at %08x len %08x (bad write was at %08x)\n" , erase.start, erase.length, eraseblocks[block_nr].flash_offset);if (ioctl (flfd,MEMERASE , &erase)) {perror ("MEMERASE" );
@@ -342,7 +342,7 @@ int main(int argc, char **argv)memcpy (eraseblocks[block_nr].wbuf, &thispkt.data[fits],PKT_SIZE - fits); eraseblocks[block_nr].wbuf_ofs =PKT_SIZE - fits; } - +if (eraseblocks[block_nr].nr_pkts == pkts_per_block) { eraseblocks[block_nr].crc =ntohl (thispkt.hdr.block_crc);
@@ -388,7 +388,7 @@ int main(int argc, char **argv)gettimeofday (&now,NULL ); fec_time += (now.tv_usec - start.tv_usec) /1000 ; fec_time += (now.tv_sec - start.tv_sec) *1000 ; - +for (i=0 ; i < pkts_per_block; i++)memcpy (&decode_buf[i*PKT_SIZE ], src_pkts[i],PKT_SIZE );
@@ -396,7 +396,7 @@ int main(int argc, char **argv)gettimeofday (&start,NULL );if (mtd_crc32 (-1 , decode_buf, meminfo.erasesize) != eraseblocks[block_nr].crc) {printf ("\nCRC mismatch for block #%d: want %08x got %08x\n" , - block_nr, eraseblocks[block_nr].crc, + block_nr, eraseblocks[block_nr].crc,mtd_crc32 (-1 , decode_buf, meminfo.erasesize));exit (1 ); }
@@ -410,7 +410,7 @@ int main(int argc, char **argv) erase.start = eraseblocks[block_nr].flash_offset; erase.length = meminfo.erasesize; - +printf ("\rErasing block at %08x..." , erase.start);if (ioctl (flfd,MEMERASE , &erase)) {
@@ -430,7 +430,7 @@ int main(int argc, char **argv)if (rwlen < meminfo.erasesize) {if (rwlen <0 ) {perror ("\ndecoded data write" ); - }else + }else fprintf (stderr,"\nshort write of decoded data\n" );if (!file_mode) {
serve_image.c +15 -15
@@ -2,13 +2,13 @@#define _POSIX_C_SOURCE 199309#include <time.h> -#include <errno.h> -#include <error.h> -#include <netdb.h> -#include <stdio.h> -#include <stdlib.h> +#include <errno.h> +#include <error.h> +#include <netdb.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h>
@@ -83,7 +83,7 @@ int main(int argc, char **argv)fprintf (stderr,"Failed to allocate last-block buffer\n" );exit (1 ); } - + fec =fec_new (pkts_per_block, total_pkts_per_block);if (!fec) {fprintf (stderr,"Error initialising FEC\n" );
@@ -93,7 +93,7 @@ int main(int argc, char **argv)memset (&hints,0 ,sizeof (hints)); hints.ai_flags =AI_ADDRCONFIG ; hints.ai_socktype =SOCK_DGRAM ; - + ret =getaddrinfo (argv[1 ], argv[2 ], &hints, &ai);if (ret) {fprintf (stderr,"getaddrinfo: %s\n" ,gai_strerror (ret));
@@ -167,9 +167,9 @@ int main(int argc, char **argv)fflush (stdout); block_crcs[block_nr] =mtd_crc32 (-1 , image + (block_nr * erasesize), erasesize); } - +printf ("\nImage size %ld KiB (0x%08lx). %d blocks at %d pkts/block\n" -"Estimated transmit time per cycle: %ds\n" , +"Estimated transmit time per cycle: %ds\n" , (long )st.st_size /1024 , (long ) st.st_size, nr_blocks, pkts_per_block, nr_blocks * pkts_per_block * pkt_delay /1000000 );
@@ -202,11 +202,11 @@ int main(int argc, char **argv)the first $pkts_per_block are cheap enough though because they're just copies. So alternate between simple and complex stuff, so that we don't start -to choke and fail to keep up with the expected +to choke and fail to keep up with the expected bitrate in the second half of the sequence */ if (block_nr &1 ) actualpkt = pkt_nr; -else +else actualpkt = total_pkts_per_block -1 - pkt_nr; blockptr = image + (erasesize * block_nr);
@@ -246,7 +246,7 @@ int main(int argc, char **argv)#endif gettimeofday (&now,NULL );#if 1 - tosleep = nextpkt.tv_usec - now.tv_usec + + tosleep = nextpkt.tv_usec - now.tv_usec + (1000000 * (nextpkt.tv_sec - now.tv_sec));/* We need hrtimers for this to actually work */
@@ -276,7 +276,7 @@ int main(int argc, char **argv)Adjust our expected timings accordingly. If we're only a little way behind, don't slip yet */ if (now.tv_usec > (now.tv_usec + (5 * pkt_delay) + -1000000 * (nextpkt.tv_sec - now.tv_sec))) { +1000000 * (nextpkt.tv_sec - now.tv_sec))) { nextpkt = now; }
@@ -291,7 +291,7 @@ int main(int argc, char **argv) writeerrors =0 ; - + } }munmap (image, st.st_size);
tests/checkfs/README +13 -13
@@ -11,11 +11,11 @@ This is the README file for the "checkfs" power fail test program. By: Vipin Malik NOTE: This program requires an external "power cycling box" -connected to one of the com ports of the system under test. -This power cycling box should wait for a random amount of time -after it receives a "ok to power me down" message over the +connected to one of the com ports of the system under test. +This power cycling box should wait for a random amount of time +after it receives a "ok to power me down" message over the serial port, and then yank power to the system under test. -(The box that I rigged up tested with waits anywhere from +(The box that I rigged up tested with waits anywhere from 0 to ~40 seconds).
@@ -75,7 +75,7 @@ some "sister" files on the root fs even though "checkfs" would run fine through all its own check files. (I found this out when one of the clobbered sister file happened -to be /bin/bash. The system refused to run rc.local thus +to be /bin/bash. The system refused to run rc.local thus preventing my "checkfs" program from being launched :) "checkfs":
@@ -98,8 +98,8 @@ Each file has a random number of bytes in it (set by using the first "int" in it (note: 0 length files are not allowed). Each file is then filled with random data and a 16 bit CRC appended at the end. -When "checkfs" is run, it runs through all files (with predetermined -file names)- one at a time- and checks for the number of "int's" +When "checkfs" is run, it runs through all files (with predetermined +file names)- one at a time- and checks for the number of "int's" in it as well as the ending CRC. The program exits if the numbers of files that are corrupt are greater
@@ -116,10 +116,10 @@ the data reliability of "other" files present of the fs, use -e 1. "other" files are defined as sister files on the fs, not being written to by the "checkfs" test program. -As mentioned, in this case you would set -e 1, or allow at most 1 file -to be corrupt each time after a power fail. This would be the file -that was probably being written to when power failed (and CRC was not -updated to reflect the new data being written). You would check file +As mentioned, in this case you would set -e 1, or allow at most 1 file +to be corrupt each time after a power fail. This would be the file +that was probably being written to when power failed (and CRC was not +updated to reflect the new data being written). You would check file systems like ext2 etc. with such a configuration. (As you have no hope that these file systems provide for either your new data or old data to be present in the file if power failed during
@@ -137,13 +137,13 @@ In other words, JFFS2 will partially update a file on FLASH even before the write() command has completed, thus leaving part old data part new data in your file if power failed in the middle of a write(). -This is bad functionality if you are updating a binary structure or a +This is bad functionality if you are updating a binary structure or a CRC protected file (as in our case). If All Files Check Out OK: -On the startup scan, if there are less errors than specified by the "-e flag" +On the startup scan, if there are less errors than specified by the "-e flag" a "ok to power me down message" is sent via the specified com port. The actual format of this message will depend on the format expected
tests/jittertest/README +9 -9
@@ -11,7 +11,7 @@ a real time task under Linux with background JFFS file system activity. The jitter is measured in milli seconds (ms) from -the expected time of arrival of a signal from a +the expected time of arrival of a signal from a periodic timer (set by the task) to when the task actually gets the signal.
@@ -20,7 +20,7 @@ This jitter is then stored in a file specified The data may also be sent out to the console by writing to /dev/console (See help options. This is -highly desirable specially if you have redirected +highly desirable specially if you have redirected your console to the serial port and are storing it as a minicom log on another computer for later analysis using some tools provided here).
@@ -82,7 +82,7 @@ supports it). In this test you would generate some background write/erase type activity that would generate chip erases. Since this program is reading from -the same file system, you contrast the latencies +the same file system, you contrast the latencies with those obtained with writes going to the same fs.
@@ -90,7 +90,7 @@ fs. file system: Here you would test for latencies experienced by -a program if it were writing (and optionally also +a program if it were writing (and optionally also reading) from a JFFS fs.
@@ -99,7 +99,7 @@ reading) from a JFFS fs. Grabing a kernel profile: This program can also conditionally grab a kernel profile. -Specify --grab_kprofile on the cmd line as well as +Specify --grab_kprofile on the cmd line as well as a "threshold" parameter (see help options by -?). Any jitter greater than this "threshold" will cause the
@@ -119,10 +119,10 @@ when you boot the kernel if you want to use this functionality. Signalling the JFFS[2] GC task: -You can also force this program to send a SIGSTOP/SIGCONT to the +You can also force this program to send a SIGSTOP/SIGCONT to the JFFS (or JFFS2) gc task by specifing --siggc <pid> on the cmd line. -This will let you investigate the effect of forcing the gc task to +This will let you investigate the effect of forcing the gc task to wake up and do its thing when you are not writing to the fs and to force it to sleep when you want to write to the fs.
@@ -130,7 +130,7 @@ These are just various tools to investigate the possibility of achieving minimal read/write latency when using JFFS[2]. You need to manually do a "ps aux" and look up the PID of the gc -thread and provide it to the program. +thread and provide it to the program.
@@ -156,7 +156,7 @@ console log or printk data). You can then run this saved console log through this program and it will output a very nice text file with the %fill in one col and -corrosponding jitter values in the second. gnuplot then does a +corrosponding jitter values in the second. gnuplot then does a beautifull plot of this resulting file showing you graphically the jitters encountered at different fill % of your JFFS[2] fs.
tests/jittertest/filljffs2.sh +1 -1
@@ -8,7 +8,7 @@ while [ $(( 1 )) -gt $(( 0 )) ] do cp $1 $2 - rm $2 + rm $2 df |grep mtd > /dev/console echo "sleeping $3" sleep $3
ubi-utils/dictionary.c +3 -3
@@ -44,7 +44,7 @@static void *mem_double (void * ptr,int size) {void * newptr ; - + newptr =calloc (2 *size,1 );if (newptr==NULL ) {return NULL ;
@@ -230,7 +230,7 @@ int dictionary_set(dictionary * d, char * key, char * val)unsigned hash ;if (d==NULL || key==NULL )return -1 ; - +/* Compute hash for this key */ hash =dictionary_hash (key) ;/* Find if value is already in dictionary */
@@ -374,7 +374,7 @@ int main(int argc, char *argv[])/* Allocate dictionary */ printf ("allocating...\n" ); d =dictionary_new (0 ); - +/* Set values in dictionary */ printf ("setting %d values...\n" ,NVALS );for (i=0 ; i<NVALS ; i++) {
ubi-utils/libiniparser.c +4 -4
@@ -82,9 +82,9 @@ static char * strstrip(char * s) {static char l[ASCIILINESZ +1 ];char * last ; - +if (s==NULL )return NULL ; - +while (isspace ((int )*s) && *s) s++;memset (l,0 ,ASCIILINESZ +1 );strcpy (l, s);
@@ -457,7 +457,7 @@ static line_status iniparser_line(char * section, char * key, char * value) -{ +{ line_status sta ;char line[ASCIILINESZ +1 ];int len ;
@@ -471,7 +471,7 @@ static line_status iniparser_line( sta =LINE_EMPTY ; }else if (line[0 ]=='#' ) {/* Comment line */ - sta =LINE_COMMENT ; + sta =LINE_COMMENT ; }else if (line[0 ]=='[' && line[len-1 ]==']' ) {/* Section name */ sscanf (line,"[%[^]]" , section);
Signature · 1 line
1.7.0.4
PATCH 6/10 mtd-utils: add common version printing function
In reply to Brian Norris--- include/common.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
include/common.h +6 -0
@@ -129,6 +129,12 @@ simple_strtoX(strtoll, long long int) simple_strtoX(strtoul, unsigned long int) simple_strtoX(strtoull, unsigned long long int) +/* Simple version-printing for utils */ +#define common_print_version () \ +do { \ + fprintf(stderr, PROGRAM_NAME " " VERSION "\n"); \ +} while (0) +#include "xalloc.h" #ifdef __cplusplus
Signature · 1 line
1.7.0.4
PATCH 7/10 mtd-utils: switch more utils to unified versioning
In reply to Brian NorrisMore utilities now use the common VERSION system.
For utils that printed a very simple message, we use the new common_print_version() "function."
--- jffs2dump.c | 2 +- mkfs.ubifs/mkfs.ubifs.c | 4 +--- ubi-utils/mtdinfo.c | 5 ++--- ubi-utils/ubiattach.c | 5 ++--- ubi-utils/ubicrc32.c | 5 ++--- ubi-utils/ubidetach.c | 5 ++--- ubi-utils/ubiformat.c | 5 ++--- ubi-utils/ubimkvol.c | 5 ++--- ubi-utils/ubinfo.c | 5 ++--- ubi-utils/ubinize.c | 5 ++--- ubi-utils/ubirename.c | 1 - ubi-utils/ubirmvol.c | 5 ++--- ubi-utils/ubirsvol.c | 5 ++--- ubi-utils/ubiupdatevol.c | 5 ++--- 14 files changed, 24 insertions(+), 38 deletions(-)
jffs2dump.c +1 -1
@@ -15,7 +15,6 @@*/ #define PROGRAM_NAME "jffs2dump" -#define VERSION "$Revision: 1.10 $"#include <errno.h> #include <stdint.h>
@@ -36,6 +35,7 @@#include <getopt.h> #include <crc32.h> #include "summary.h" +#include "common.h" #define PAD (x) (((x)+3)&~3)
mkfs.ubifs/mkfs.ubifs.c +1 -3
@@ -26,8 +26,6 @@#include <crc32.h> #include "common.h" -#define PROGRAM_VERSION "1.5" -/* Size (prime number) of hash table for link counting */ #define HASH_TABLE_SIZE 10099
@@ -606,7 +604,7 @@ static int get_options(int argc, char**argv) verbose =1 ;break ;case 'V' : -printf ("Version " PROGRAM_VERSION "\n" ); +common_print_version ();exit (0 );case 'g' : debug_level =strtol (optarg, &endp,0 );
ubi-utils/mtdinfo.c +2 -3
@@ -21,7 +21,6 @@* Author: Artem Bityutskiy */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "mtdinfo"#include <stdint.h>
@@ -53,7 +52,7 @@ static struct args args = { .node = NULL, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to print MTD information." ; static const char optionsstr[] =
@@ -125,7 +124,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -printf ("%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubiattach.c +2 -3
@@ -21,7 +21,6 @@* Author: Artem Bityutskiy */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubiattach"#include <stdio.h>
@@ -53,7 +52,7 @@ static struct args args = { .dev = NULL, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to attach MTD device to UBI." ; static const char optionsstr[] =
@@ -129,7 +128,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubicrc32.c +2 -3
@@ -22,7 +22,6 @@* Author: Oliver Lohmann */ -#define PROGRAM_VERSION "1.0"#define PROGRAM_NAME "ubicrc32"#include <stdio.h>
@@ -37,7 +36,7 @@#define BUFSIZE 4096 -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to calculate CRC32 with UBI start value (0xFFFFFFFF)" ; static const char optionsstr[] =
@@ -70,7 +69,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubidetach.c +2 -3
@@ -21,7 +21,6 @@* Author: Artem Bityutskiy */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubidetach"#include <stdio.h>
@@ -50,7 +49,7 @@ static struct args args = { .dev = NULL, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - tool to remove UBI devices (detach MTD devices from UBI)" ; static const char optionsstr[] =
@@ -113,7 +112,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubiformat.c +2 -3
@@ -29,7 +29,6 @@*/ #define MAX_CONSECUTIVE_BAD_BLOCKS 4 -#define PROGRAM_VERSION "1.5"#define PROGRAM_NAME "ubiformat"#include <sys/stat.h>
@@ -72,7 +71,7 @@ static struct args args = .ubi_ver = 1, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to format MTD devices and flash UBI images" ; static const char optionsstr[] =
@@ -206,7 +205,7 @@ static int parse_opt(int argc, char * const argv[])break ;case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case 'h' :
ubi-utils/ubimkvol.c +2 -3
@@ -23,7 +23,6 @@* Frank Haverkamp <[email protected]> */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubimkvol"#include <stdio.h>
@@ -56,7 +55,7 @@ static struct args args = { .vol_id = UBI_VOL_NUM_AUTO, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to create UBI volumes." ; static const char optionsstr[] =
@@ -173,7 +172,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case 'm' :
ubi-utils/ubinfo.c +2 -3
@@ -21,7 +21,6 @@* Author: Artem Bityutskiy */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubinfo"#include <stdint.h>
@@ -51,7 +50,7 @@ static struct args args = { .vol_name = NULL, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to print UBI information." ; static const char optionsstr[] =
@@ -124,7 +123,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubinize.c +2 -3
@@ -24,7 +24,6 @@* Oliver Lohmann */ -#define PROGRAM_VERSION "1.2"#define PROGRAM_NAME "ubinize"#include <sys/stat.h>
@@ -39,7 +38,7 @@#include "common.h" #include "ubiutils-common.h" -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to generate UBI images. An UBI image may contain one or more UBI " "volumes which have to be defined in the input configuration ini-file. The " "ini file defines all the UBI volumes - their characteristics and the and the "
@@ -234,7 +233,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );default :
ubi-utils/ubirename.c +0 -1
@@ -21,7 +21,6 @@* Author: Richard Titmuss */ -#define PROGRAM_VERSION "1.0"#define PROGRAM_NAME "ubirename"#include <stdio.h>
ubi-utils/ubirmvol.c +2 -3
@@ -23,7 +23,6 @@* Frank Haverkamp <[email protected]> */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubirmvol"#include <stdio.h>
@@ -46,7 +45,7 @@ static struct args args = { .vol_id = -1, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to remove UBI volumes." ; static const char optionsstr[] =
@@ -117,7 +116,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubirsvol.c +2 -3
@@ -23,7 +23,6 @@* Frank Haverkamp <[email protected]> */ -#define PROGRAM_VERSION "1.1"#define PROGRAM_NAME "ubirsvol"#include <stdio.h>
@@ -51,7 +50,7 @@ static struct args args = { .lebs = -1, }; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to resize UBI volumes." ; static const char optionsstr[] =
@@ -146,7 +145,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
ubi-utils/ubiupdatevol.c +2 -3
@@ -24,7 +24,6 @@* Artem Bityutskiy */ -#define PROGRAM_VERSION "1.2"#define PROGRAM_NAME "ubiupdatevol"#include <fcntl.h>
@@ -52,7 +51,7 @@ struct args {static struct args args; -static const char doc[] =PROGRAM_NAME " version " PROGRAM_VERSION +static const char doc[] =PROGRAM_NAME " version " VERSION " - a tool to write data to UBI volumes." ; static const char optionsstr[] =
@@ -103,7 +102,7 @@ static int parse_opt(int argc, char * const argv[])exit (EXIT_SUCCESS );case 'V' : -fprintf (stderr,"%s\n" ,PROGRAM_VERSION ); +common_print_version ();exit (EXIT_SUCCESS );case ':' :
Signature · 1 line
1.7.0.4
PATCH 5/10 mkfs.ubifs: use common.h
In reply to Brian NorrisTo use more unified versioning and to re-use other existing code, switch to common.h.
--- mkfs.ubifs/mkfs.ubifs.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
mkfs.ubifs/mkfs.ubifs.c +3 -5
@@ -20,8 +20,11 @@* Zoltan Sogor */ +#define PROGRAM_NAME "mkfs.ubifs" +#include "mkfs.ubifs.h" #include <crc32.h> +#include "common.h" #define PROGRAM_VERSION "1.5"
@@ -390,11 +393,6 @@ static long long add_space_overhead(long long size)return size / divisor; } -static inline int is_power_of_2 (unsigned long long n) -{ -return (n !=0 && ((n & (n -1 )) ==0 )); -} -static int validate_options (void ) {int tmp;
Signature · 1 line
1.7.0.4
PATCH 4/10 mtd-utils: update .gitignore files
In reply to Brian NorrisFirst, the top-level Makefile should not tell git to ignore sub-level .gitignore files.
Second, add simple .gitignores to ignore the executables generated under the various `tests' subdirectories.
--- .gitignore | 5 +++++ tests/checkfs/.gitignore | 2 ++ tests/fs-tests/integrity/.gitignore | 1 + tests/fs-tests/simple/.gitignore | 5 +++++ tests/fs-tests/stress/atoms/.gitignore | 10 ++++++++++ tests/fs-tests/utils/.gitignore | 2 ++ tests/jittertest/.gitignore | 2 ++ 7 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 tests/checkfs/.gitignore create mode 100644 tests/fs-tests/integrity/.gitignore create mode 100644 tests/fs-tests/simple/.gitignore create mode 100644 tests/fs-tests/stress/atoms/.gitignore create mode 100644 tests/fs-tests/utils/.gitignore create mode 100644 tests/jittertest/.gitignore
.gitignore +5 -0
@@ -48,6 +48,11 @@ # # +# git files that we don't want to ignore even it they are dot-files +# +!.gitignore + +# # Generated include files # /include/version.h
tests/checkfs/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/checkfs +/makefiles
tests/fs-tests/integrity/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/integck
tests/fs-tests/simple/.gitignore new file +5 -0
@@ -0,0 +1,5 @@ +/ftrunc +/orph +/perf +/test_1 +/test_2
tests/fs-tests/stress/atoms/.gitignore new file +10 -0
@@ -0,0 +1,10 @@ +/fwrite00 +/gcd_hupper +/pdfrun +/rmdir00 +/rndrm00 +/rndrm99 +/rndwrite00 +/stress_1 +/stress_2 +/stress_3
tests/fs-tests/utils/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/free_space +/fstest_monitor
tests/jittertest/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/JitterTest +/plotJittervsFill
Signature · 1 line
1.7.0.4
PATCH 8/10 mtd-utils: kill flash_info
In reply to Brian NorrisAccording to "feature-removal-schedule," we kill flash_info in favor of mtdinfo.
--- Makefile | 2 +- feature-removal-schedule.txt | 6 ---- flash_info.c | 67 ------------------------------------------ 3 files changed, 1 insertions(+), 74 deletions(-) delete mode 100644 flash_info.c
Makefile +1 -1
@@ -18,7 +18,7 @@ TESTS = tests MTD_BINS = \ ftl_format flash_erase nanddump doc_loadbios \ - ftl_check mkfs.jffs2 flash_lock flash_unlock flash_info \ + ftl_check mkfs.jffs2 flash_lock flash_unlock \ flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite nandtest \ jffs2dump \ nftldump nftl_format docfdisk \
feature-removal-schedule.txt +0 -6
@@ -34,9 +34,3 @@ the -m option. For now, we just have a warning, but the option will be removed in release 1.4.6. --------------------------- -3. flash_info utility - -This is duplicating behavior with the mtdinfo utility. Now the util -warns when people use it, but it'll be removed in release 1.4.6. - ----------------------------
flash_info.c deleted +0 -67
67 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 9/10 mtdinfo: kill -m option
In reply to Brian NorrisAccording to feature-removal-schedule, we shouldn't use `-m', since it relies on a specific device-naming pattern.
--- feature-removal-schedule.txt | 8 -------- ubi-utils/mtdinfo.c | 25 ++++++------------------- 2 files changed, 6 insertions(+), 27 deletions(-)
feature-removal-schedule.txt +0 -8
@@ -26,11 +26,3 @@ to stop using them. The further step is to remove both of them. --------------------------- -2. Kill -m parameter of mtdinfo - -We cannot assume that mtd device names follow the "/dev/mtd%d" pattern, -because it is up to udev rules to name the devices. So we are removing -the -m option. For now, we just have a warning, but the option will be -removed in release 1.4.6. - ----------------------------
ubi-utils/mtdinfo.c +6 -19
@@ -56,8 +56,6 @@ static const char doc[] = PROGRAM_NAME " version " VERSION" - a tool to print MTD information." ;static const char optionsstr[] = -"-m, --mtdn=<MTD device number> MTD device number to get information about\n" -" (deprecated option, will be removed, do not use)\n" "-u, --ubi-info print what would UBI layout be if it was put\n" " on this MTD device\n" "-M, --map print eraseblock map\n"
@@ -66,20 +64,16 @@ static const char optionsstr[] ="-V, --version print program version" ;static const char usage[] = -"Usage 1: " PROGRAM_NAME " [-m <MTD device number>] [-u] [-M] [-h] [-V] [--mtdn <MTD device number>]\n" -"\t\t[--ubi-info] [--help] [--version]\n" -"Usage 2: " PROGRAM_NAME " <MTD device node file name> [-u] [-M] [-h] [-V] [--ubi-info] [--help]\n" +"Usage: " PROGRAM_NAME " <MTD device node file name> [-u] [-M] [-h] [-V] [--ubi-info] [--help]\n" "\t\t[--version]\n" "Example 1: " PROGRAM_NAME " - (no arguments) print general MTD information\n" -"Example 2: " PROGRAM_NAME " -m 1 - print information about MTD device number 1\n" -"Example 3: " PROGRAM_NAME " /dev/mtd0 - print information MTD device /dev/mtd0\n" -"Example 4: " PROGRAM_NAME " /dev/mtd0 -u - print information MTD device /dev/mtd0\n" +"Example 2: " PROGRAM_NAME " /dev/mtd0 - print information MTD device /dev/mtd0\n" +"Example 3: " PROGRAM_NAME " /dev/mtd0 -u - print information MTD device /dev/mtd0\n" "\t\t\t\tand include UBI layout information\n" -"Example 5: " PROGRAM_NAME " -a - print information about all MTD devices\n" +"Example 4: " PROGRAM_NAME " -a - print information about all MTD devices\n" "\t\t\tand include UBI layout information\n" ;static const struct option long_options[] = { - { .name ="mtdn" , .has_arg =1 , .flag =NULL , .val ='m' }, { .name ="ubi-info" , .has_arg =0 , .flag =NULL , .val ='u' }, { .name ="map" , .has_arg =0 , .flag =NULL , .val ='M' }, { .name ="all" , .has_arg =0 , .flag =NULL , .val ='a' },
@@ -91,9 +85,9 @@ static const struct option long_options[] = {static int parse_opt (int argc,char *const argv[]) {while (1 ) { -int key, error =0 ; +int key; - key =getopt_long (argc, argv,"am:uMhV" , long_options,NULL ); + key =getopt_long (argc, argv,"auMhV" , long_options,NULL );if (key ==-1 )break ;
@@ -106,13 +100,6 @@ static int parse_opt(int argc, char * const argv[]) args.ubinfo =1 ;break ; -case 'm' : - args.mtdn =simple_strtoul (optarg, &error); -if (error || args.mtdn <0 ) -return errmsg ("bad MTD device number: \"%s\"" , optarg); -warnmsg ("-m/--mtdn is depecated, will be removed in mtd-utils-1.4.6" ); -break ; -case 'M' : args.map =1 ;break ;
Signature · 1 line
1.7.0.4
PATCH 10/10 nanddump: remove unused variable
In reply to Brian NorrisThe "bb_default" bool was temporarily being used to straighten out potential issues with the changing --bb=METHOD options and to warn users properly. Now, it's unnecessary.
--- nanddump.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
nanddump.c +1 -2
@@ -102,7 +102,7 @@ static enum {static void process_options (int argc,char *const argv[]) {int error =0 ; -bool bb_default = true, oob_default = true; +bool oob_default = true;for (;;) {int option_index =0 ;
@@ -149,7 +149,6 @@ static void process_options(int argc, char * const argv[]) bb_method = skipbad; else error++; - bb_default = false;break ;case 3 :/* --omitoob */ if (oob_default) {
Signature · 1 line
1.7.0.4
Re: [PATCH 06/10] mtd-utils: add common version printing function
In reply to Brian Norrisinclude/common.h simple_strtoX(strtoll, long long int) · line 136
Quoted 5 lines · Brian Norris
include/common.h +5
-0+/* Simple version-printing for utils */ +#define common_print_version () \ +do { \ + fprintf(stderr, PROGRAM_NAME " " VERSION "\n"); \ +} while (0)
this shouldnt go to stderr
if the string is const, then it could just be puts(). but i wonder if it shouldnt instead use printf("%s %s\n", PROGRAM_NAME, VERSION) so that the string that represents PROGRAM_NAME isn't duplicated in the .rodata section.
-mike
except for the one i commented on, the rest look fine to me
-mike
Re: [PATCH 06/10] mtd-utils: add common version printing function
In reply to Mike FrysingerQuoted 8 lines · Mike Frysinger
include/common.h simple_strtoX(strtoll, long long int) · line 136
Quoted 5 lines · Brian Norris
include/common.h +5
-0+/* Simple version-printing for utils */ +#define common_print_version () \ +do { \ + fprintf(stderr, PROGRAM_NAME " " VERSION "\n"); \ +} while (0)this shouldnt go to stderr
Yeah, I wasn't too sure on that one. There were several utils that already used stderr, but that doesn't actually make much sense, I guess.
Quoted 4 lines
if the string is const, then it could just be
puts(). but i wonder if it shouldnt instead useprintf("%s %s\n", PROGRAM_NAME, VERSION)so that the string that representsPROGRAM_NAMEisn't duplicated in the .rodata section.
I'm not sure I know what the exact technical difference would be between the string concatenation version and the '%s' argument version...
Brian
Re: [PATCH 06/10] mtd-utils: add common version printing function
Quoted 9 lines · Brian Norris
Quoted 4 lines · Mike Frysinger
if the string is const, then it could just be
puts(). but i wonder if it shouldnt instead useprintf("%s %s\n", PROGRAM_NAME, VERSION)so that the string that representsPROGRAM_NAMEisn't duplicated in the .rodata section.I'm not sure I know what the exact technical difference would be between the string concatenation version and the '%s' argument version...
"%s %s\n" is one string in .rodata, and PROGRAM_NAME is another. so anytime the app uses PROGRAM_NAME (like in all the helpers in common.h), they'll reuse that same PROGRAM_NAME string rather than constantly duplicating it.
if however you use PROGRAM_NAME " " VERSION, you have a unique string that is only used by the version code.
minor details, but all these duplicate const strings slowly add up ... -mike
Quoted 3 lines · Mike Frysinger
except for the one i commented on, the rest look fine to me
Acked-by Mike Frysinger <[email protected]>-mike
Thanks. I'll send v2 soon if I don't get any more comments.
Brian
Re: [PATCH 09/10] mtdinfo: kill -m option
In reply to Brian NorrisQuoted 8 lines · Brian Norris
According to feature-removal-schedule, we shouldn't use `-m', since it relies on a specific device-naming pattern.
Signed-off-by Brian Norris <[email protected]>--- feature-removal-schedule.txt | 8 -------- ubi-utils/mtdinfo.c | 25 ++++++------------------- 2 files changed, 6 insertions(+), 27 deletions(-)
Pushed the series, thanks! I would also like to add the following patch on top of your series, is ok with you?
From: Artem Bityutskiy <[email protected]>
Date: Wed, 29 Jun 2011 08:56:39 +0300
Subject: [PATCH] mtdinfo: remove -m leftovers
We have removed the -m option, but did not remove args.mtdn which represents the -m parameters. Kill args.mtdn as well.
--- ubi-utils/mtdinfo.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
ubi-utils/mtdinfo.c +9 -13
@@ -128,10 +128,8 @@ static int parse_opt(int argc, char * const argv[])else if (optind < argc)return errmsg ("more then one MTD device specified (use -h for help)" ); -if (args.all && (args.node || args.mtdn !=-1 )) { - args.mtdn =-1 ; +if (args.all && args.node) args.node =NULL ; - }if (args.map && !args.node)return errmsg ("-M requires MTD device node name" );
@@ -153,8 +151,7 @@ static int translate_dev(libmtd_t libmtd, const char *node) "device \"%s\"", node); } - args.mtdn = mtd.mtd_num; -return 0 ; +return mtd.mtd_num; } static void print_ubi_info(const struct mtd_info *mtd_info,
@@ -406,20 +403,19 @@ int main(int argc, char * const argv[])return sys_errmsg ("cannot get MTD information" ); } -if (args.node) { +if (!args.all) { +int mtdn; +/* * A character device was specified, translate this to MTD * device number. */ - err =translate_dev (libmtd, args.node); -if (err) + mtdn =translate_dev (libmtd, args.node); +if (mtdn <0 ) goto out_libmtd; - } - -if (args.mtdn ==-1 ) + err =print_dev_info (libmtd, &mtd_info, mtdn); + }else err =print_general_info (libmtd, &mtd_info, args.all); -else - err =print_dev_info (libmtd, &mtd_info, args.mtdn);if (err) goto out_libmtd;
Signature · 6 lines
1.7.5.4 -- Best Regards, Artem Bityutskiy
Re: [PATCH 02/10] mtd-tests: io_paral: build error, "variable length strings"
In reply to Brian NorrisQuoted 7 lines · Brian Norris
Some compilers will complain about use of
strlen()within a static array size declaration. For this type of string, "sizeof()- 1" is equivalent and prevents the build error.Error:
io_paral.c:48:13: error: variably modified '
vol_nodes' at file scope
Out of curiosity, which compiler does that? Newer versions of GCC, or some other compiler altogether?
josh
Re: [PATCH 02/10] mtd-tests: io_paral: build error, "variable length strings"
Quoted 6 lines · Josh Boyer
Quoted 4 lines · Brian Norris
Some compilers will complain about use of
strlen()within a static array size declaration. For this type of string, "sizeof()- 1" is equivalent and prevents the build error.
Quoted 6 lines
Quoted 3 lines
Error:
io_paral.c:48:13: error: variably modified '
vol_nodes' at file scopeOut of curiosity, which compiler does that? Newer versions of GCC, or some other compiler altogether?
I think it's just newer versions of GCC. I found the error on MIPS GCC on versions 4.5.2 and 4.5.3. It didn't occur on MIPS or x86_64 for version 4.4.3.
Brian
PATCH v2 1/1 mtdinfo: remove -m leftovers
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Looks OK to me, except it seems you did everything but actually removing the field in struct args :) So here's a quick v2 from me...
From: Artem Bityutskiy <[email protected]>
Date: Wed, 29 Jun 2011 08:56:39 +0300
Subject: [PATCH v2] mtdinfo: remove -m leftovers
We have removed the -m option, but did not remove args.mtdn which represents the -m parameters. Kill args.mtdn as well.
--- ubi-utils/mtdinfo.c | 24 +++++++++--------------- 1 files changed, 9 insertions(+), 15 deletions(-)
ubi-utils/mtdinfo.c +9 -15
@@ -38,7 +38,6 @@/* The variables below are set by command line arguments */ struct args { -int mtdn;unsigned int all:1 ;unsigned int ubinfo:1 ;unsigned int map:1 ;
@@ -46,7 +45,6 @@ struct args { };static struct args args = { - .mtdn =-1 , .ubinfo =0 , .all =0 , .node =NULL ,
@@ -128,10 +126,8 @@ static int parse_opt(int argc, char * const argv[])else if (optind < argc)return errmsg ("more then one MTD device specified (use -h for help)" ); -if (args.all && (args.node || args.mtdn !=-1 )) { - args.mtdn =-1 ; +if (args.all && args.node) args.node =NULL ; - }if (args.map && !args.node)return errmsg ("-M requires MTD device node name" );
@@ -153,8 +149,7 @@ static int translate_dev(libmtd_t libmtd, const char *node) "device \"%s\"", node); } - args.mtdn = mtd.mtd_num; -return 0 ; +return mtd.mtd_num; } static void print_ubi_info(const struct mtd_info *mtd_info,
@@ -406,20 +401,19 @@ int main(int argc, char * const argv[])return sys_errmsg ("cannot get MTD information" ); } -if (args.node) { +if (!args.all) { +int mtdn; +/* * A character device was specified, translate this to MTD * device number. */ - err =translate_dev (libmtd, args.node); -if (err) + mtdn =translate_dev (libmtd, args.node); +if (mtdn <0 ) goto out_libmtd; - } - -if (args.mtdn ==-1 ) + err =print_dev_info (libmtd, &mtd_info, mtdn); + }else err =print_general_info (libmtd, &mtd_info, args.all); -else - err =print_dev_info (libmtd, &mtd_info, args.mtdn);if (err) goto out_libmtd;
Signature · 1 line
1.7.0.4
Re: [PATCH v2] mtdinfo: remove -m leftovers
Quoted 9 lines · Brian Norris
From: Artem Bityutskiy <[email protected]>
Looks OK to me, except it seems you did everything but actually removing the field in struct args :) So here's a quick v2 from me...
From: Artem Bityutskiy <[email protected]>
Date: Wed, 29 Jun 2011 08:56:39 +0300
Subject: [PATCH v2] mtdinfo: remove -m leftovers
Quoted 5 lines
We have removed the -m option, but did not remove args.mtdn which represents the -m parameters. Kill args.mtdn as well.
Signed-off-by Artem Bityutskiy <[email protected]>Signed-off-by Brian Norris <[email protected]>
Pushed, thanks you!
Signature · 2 lines
Best Regards, Artem Bityutskiy