Re: [Suspend-devel] [PATCH] "program swap-offset is using a deprecated SCSI ioctl"

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

 



On Monday 24 August 2009, Alan Jenkins wrote:
> "program swap-offset is using a deprecated SCSI ioctl"
> 
> <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=425219>
> 
> The debian uswsusp package tries to run swap-offset even if the
> swap is a partition and not a file.  Calling FIGETBSZ on a scsi disk
> device provokes the alarming kernel warning above.  (Alarming
> because it suggests that FIGETBSZ might somehow be interpreted as a
> random SCSI ioctl).
> 
> Let's check explicitly whether we've been given a regular file.

I've just found this patch in the archives, so sorry for the glacial delay.

I applied it to the suspend-utils tree at kernel.org.

Thanks,
Rafael


> ---
>  swap-offset.c |   15 ++++++++++-----
>  1 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/swap-offset.c b/swap-offset.c
> index b0cccca..79aeef7 100644
> --- a/swap-offset.c
> +++ b/swap-offset.c
> @@ -47,6 +47,16 @@ int main(int argc, char **argv)
>  		perror("open()");
>  		return err;
>  	}
> +	if (fstat(fd, &stat)) {
> +		err = errno;
> +		perror("fstat()");
> +		goto out;
> +	}
> +	if (!S_ISREG(stat.st_mode)) {
> +		fprintf(stderr, "Not a regular file\n");
> +		err = EINVAL;
> +		goto out;
> +	}
>  
>  	/* Check swap signature */
>  	if (lseek(fd, page_size - SWAP_SIG_SIZE, SEEK_SET) < 0) {
> @@ -71,11 +81,6 @@ int main(int argc, char **argv)
>  		goto out;
>  	}
>  
> -	if (fstat(fd, &stat)) {
> -		err = errno;
> -		perror("fstat()");
> -		goto out;
> -	}
>  	if (ioctl(fd, FIGETBSZ, &blk_size)) {
>  		err = errno;
>  		perror("ioctl(FIGETBSZ) failed");
> 
> 
> 
> ------------------------------------------------------------------------------
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

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

  Powered by Linux