Util-Linux package development
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: kerolasa@gmail.com
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [git pull] cramfs fixes
Date: Thu, 21 Jul 2011 20:10:12 +0200	[thread overview]
Message-ID: <20110721181012.GA6672@nb.net.home> (raw)
In-Reply-To: <CAG27Bk1uKnqR62SRNgTXFPGfTseraC0AUgpAMQ5zhdcsAM-79w@mail.gmail.com>

On Wed, Jul 20, 2011 at 10:55:16PM +0200, Sami Kerola wrote:
> +	/*
> +	 * NAMELEN is the length of the file name, divided by 4 and
> +	 * rounded up.  (cramfs doesn't support hard links.)
> +	 *
> +	 * OFFSET: For symlinks and non-empty regular files, this
> +	 * contains the offset (divided by 4) of the file data in
> +	 * compressed form (starting with an array of block pointers;
> +	 * see README).  For non-empty directories it is the offset
> +	 * (divided by 4) of the inode of the first file in that
> +	 * directory.  For anything else, offset is zero.
> +	 */
>  	u32 namelen:6, offset:26;
    ^^^
 uint32_t

> +/* Exit codes used by fsck-type programs */
> +#define FSCK_OK			0	/* No errors */
> +#define FSCK_NONDESTRUCT	1	/* File system errors corrected */
> +#define FSCK_REBOOT		2	/* System should be rebooted */
> +#define FSCK_UNCORRECTED	4	/* File system errors left uncorrected */
> +#define FSCK_ERROR		8	/* Operational error */
> +#define FSCK_USAGE		16	/* Usage or syntax error */
> +#define FSCK_LIBRARY		128	/* Shared library error */

 I see magic numbers also in fsck.minix ;-)

 What about to add include/exitcodes.h and move this and
 disk-utils/mkfs.h to this file?

>  		if (size >= page_size) {
> -			if (out != page_size) {
> -				die(FSCK_UNCORRECTED, 0, _("non-block (%ld) bytes"), out);
> -			}
> -		} else {
> -			if (out != size) {
> -				die(FSCK_UNCORRECTED, 0, _("non-size (%ld vs %ld) bytes"), out, size);
> -			}
> -		}
> -		size -= out;
> -		if (opt_extract) {
> -			if (write(fd, outbuffer, out) < 0) {
> -				die(FSCK_ERROR, 1, _("write failed: %s"), path);
> -			}
> +			if (out != page_size)
> +				errx(FSCK_UNCORRECTED,
> +				     _("non-block (%ld) bytes"), out);
> +			else if (out != size)

        } else if (out != size)
       ^^^   

> +				errx(FSCK_UNCORRECTED,
> +				     _("non-size (%ld vs %ld) bytes"), out,
> +				     size);
> +			size -= out;
> +			if (opt_extract)
> +				if (write(fd, outbuffer, out) < 0)
> +					err(FSCK_ERROR, _("write failed: %s"),
> +					    path);
> +			curr = next;
>  		}
       ^^^

the 'if (opt_extract)' block is outsize 'if (size >= page_size)'...

> -		curr = next;
>  	} while (size);
>  }
> -		if ((S_ISUID | S_ISGID) & i->mode) {
> -			if (chmod(path, i->mode) < 0) {
> -				die(FSCK_ERROR, 1, _("chown failed: %s"), path);
> -			}
> -		}
> +		if ((S_ISUID | S_ISGID) & i->mode)
> +			if (chmod(path, i->mode) < 0)
> +				err(FSCK_ERROR, _("chown failed: %s"), path);
>  	}

      if (((S_ISUID | S_ISGID) & i->mode) && chmod(path, i->mode) < 0)
           err(FSCK_ERROR, _("chown failed: %s"), path);

[...]

>  	while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) {
>  		switch (c) {
>  		case 'h':
> -			usage(0);
> +			usage(MKFS_OK);
>  		case 'b':
> -			blksize = atoi(optarg);
> +			blksize = strtoll_or_err(optarg, _("blocksize argument failed"));

 hmm... "failed to parse blocksize argument" ?

 [...]

>  			else if (strcmp(optarg, "host") == 0);	/* default */
> -			else 	{
> -				perror("invalid endianness given. Must be 'big', 'little', or 'host'");
> -				exit(MKFS_USAGE);
> -			}
> +			else
> +				errx(MKFS_USAGE, _("invalid endianness given."
> +						   " Must be 'big', 'little', or 'host'"));

   else if (strcmp(optarg, "host") == 0)
        ; /* default */
   else {
        ....
   }

>  		case 'V':
>  			printf(_("%s (%s)\n"),

 "%s from %s\n" :-)

> -			       progname, PACKAGE_STRING);
> +			       program_invocation_short_name, PACKAGE_STRING);

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2011-07-21 18:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 20:55 [git pull] cramfs fixes Sami Kerola
2011-07-21 18:10 ` Karel Zak [this message]
2011-07-22  7:56   ` Sami Kerola
2011-07-26 14:25     ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110721181012.GA6672@nb.net.home \
    --to=kzak@redhat.com \
    --cc=kerolasa@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox