Re: [PATCH] mkswap: Set UUID for swap space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 27, 2008 at 02:37:13AM -0500, Mike Frysinger wrote:
> On Sunday 27 January 2008, LaMont Jones wrote:
> > @@ -523,6 +525,12 @@ main(int argc, char ** argv) {
> >  				case 'v':
> >  					version = atoi(argv[i]+2);
> >  					break;
> > +				case 'U':
> > +					set_uuid = 1;
> > +					uuid_input = argv[i]+2;
> > +					if (!*uuid_input && i+1 < argc)
> > +						uuid_input = argv[++i];
> > +					break;
> >  				default:
> >  					usage();
> >  			}
> 
> you should error out if HAVE_LIBUUID is not defined and someone tries to 
> use -U since it obviously isnt going to work
> 
> >  #ifdef HAVE_LIBUUID
> > -	uuid_generate(uuid_dat);
> > -	uuid = uuid_dat;
> > +	if(!set_uuid)
> > +	{
> > + 	  uuid_generate(uuid_dat);
> > +    	  uuid = uuid_dat;
> > +	} else {
> > +	  uuid_parse(uuid_input, uuid_dat);
> > +	  uuid = uuid_dat;
> > +	}
> 
> there's no point in the braces since the second statement is the same ... just 
> move the uuid assignment outside of the if block and drop the braces 
> (especially since the first brace would have needed to be cuddled up anyways)

 ... and check for error:

    if (uuid_parse(uuid_input, uuid_dat) != 0) {
        fprintf(stderr, _("%s: error: unable parse UUID\n"),
                                program_name);
        exit(1);
    }

 ... and don't forget to update mkswap.8 man page.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux