All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs
Date: Wed, 22 Nov 2017 15:58:22 +0100	[thread overview]
Message-ID: <20171122145822.GF2389@rei.lan> (raw)
In-Reply-To: <1510818534-7378-1-git-send-email-yangx.jy@cn.fujitsu.com>

Hi!
>  static int attach_device(const char *dev, const char *file)
>  {
>  	int dev_fd, file_fd;
> +	struct loop_info loopinfo;
>  
>  	dev_fd = open(dev, O_RDWR);
>  	if (dev_fd < 0) {
> @@ -156,6 +157,21 @@ static int attach_device(const char *dev, const char *file)
>  		return 1;
>  	}
>  
> +	/* Old mkfs.btrfs use LOOP_GET_STATUS instead of backing_file to get
> +	 * associated filename, so we need to set up the device by calling
> +	 * LOOP_SET_FD and LOOP_SET_STATUS.
> +	 */
> +	memset(&loopinfo, 0, sizeof(loopinfo));
> +	strcpy((char *)loopinfo.lo_name, file);
                 ^
		 Why the cast here, as far as I can tell the lo_name is
		 just array of chars which should be char * pointer
		 compatible.

> +	if (ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo)) {
> +		close(dev_fd);
> +		close(file_fd);
> +		tst_resm(TWARN | TERRNO,
> +			 "ioctl(%s, LOOP_SET_STATUS, %s) failed", dev, file);
> +		return 1;
> +	}
> +
>  	close(dev_fd);
>  	close(file_fd);
>  	return 0;

Otherwise it looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2017-11-22 14:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16  7:48 [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs Xiao Yang
2017-11-22 14:58 ` Cyril Hrubis [this message]
2017-11-23  1:36   ` [LTP] [PATCH v2] lib/tst_device.c: " Xiao Yang
2017-11-23 11:50     ` Cyril Hrubis

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=20171122145822.GF2389@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.