Re: [PATCH 2/2] swapon: add swap format detection

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

 



On Thu, Nov 27, 2008 at 12:32:56PM +0100, Matthias Koenig wrote:

 Applied with some minor changes, thanks.

> +	if (read(fd, buf, MAX_PAGESIZE) == (ssize_t)-1) {
> +		perror("read");
> +		goto err1;
> +	}

 committed:

 +       datasz = read(fd, buf, MAX_PAGESIZE);
 +       if (datasz == (ssize_t) -1) {
 +               perror("read");
 +               goto err1;
 +       }

> +
> +	for (page = 0x1000; page <= MAX_PAGESIZE; page <<= 1) {
> +		/* skip 32k pagesize since this does not seem to
> +		 * be supported */
> +		if (page == 0x8000)
> +			continue;

  +     /* the smallest swap area is PAGE_SIZE*10, it means
  +      * 40k, that's less than MAX_PAGESIZE */
  +     if (datasz < (page - 10))
  +         break;

 in theory the read() can also returns less then requested.


    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