From: Omar Sandoval <osandov@osandov.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-block@vger.kernel.org, Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH 1/2] loop/006: Add test for setting partscan flag
Date: Mon, 22 Oct 2018 15:52:55 -0700 [thread overview]
Message-ID: <20181022225255.GB10074@vader> (raw)
In-Reply-To: <20181018103147.3567-2-jack@suse.cz>
On Thu, Oct 18, 2018 at 12:31:46PM +0200, Jan Kara wrote:
> Add test for setting partscan flag.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Sorry I didn't notice this earlier, but loop/001 already does a
partition rescan (via losetup -P). Does that cover this test case?
> ---
> src/Makefile | 3 ++-
> src/loop_set_status_partscan.c | 45 ++++++++++++++++++++++++++++++++++++++++++
> tests/loop/006 | 33 +++++++++++++++++++++++++++++++
> tests/loop/006.out | 2 ++
> 4 files changed, 82 insertions(+), 1 deletion(-)
> create mode 100644 src/loop_set_status_partscan.c
> create mode 100755 tests/loop/006
> create mode 100644 tests/loop/006.out
>
> diff --git a/src/Makefile b/src/Makefile
> index f89f61701179..6dadcbec8beb 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -4,7 +4,8 @@ C_TARGETS := \
> openclose \
> sg/dxfer-from-dev \
> sg/syzkaller1 \
> - nbdsetsize
> + nbdsetsize \
> + loop_set_status_partscan
>
> CXX_TARGETS := \
> discontiguous-io
> diff --git a/src/loop_set_status_partscan.c b/src/loop_set_status_partscan.c
> new file mode 100644
> index 000000000000..8873a12e4334
> --- /dev/null
> +++ b/src/loop_set_status_partscan.c
> @@ -0,0 +1,45 @@
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/ioctl.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
> +#include <linux/loop.h>
> +
> +void usage(const char *progname)
> +{
> + fprintf(stderr, "usage: %s PATH\n", progname);
> + exit(EXIT_FAILURE);
> +}
> +
> +int main(int argc, char **argv)
> +{
> + int ret;
> + int fd;
> + struct loop_info64 info;
> +
> + if (argc != 2)
> + usage(argv[0]);
> +
> + fd = open(argv[1], O_RDONLY);
> + if (fd == -1) {
> + perror("open");
> + return EXIT_FAILURE;
> + }
> +
> + memset(&info, 0, sizeof(info));
> + info.lo_flags = LO_FLAGS_PARTSCAN;
> + memcpy(info.lo_file_name, "part", 5);
What's the significance of this file name?
> + ret = ioctl(fd, LOOP_SET_STATUS64, &info);
> + if (ret == -1) {
> + perror("ioctl");
> + close(fd);
> + return EXIT_FAILURE;
> + }
> + close(fd);
> + return EXIT_SUCCESS;
> +}
[snip]
next prev parent reply other threads:[~2018-10-23 7:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 10:31 [PATCH 0/2] blktests: New loop tests Jan Kara
2018-10-18 10:31 ` [PATCH 1/2] loop/006: Add test for setting partscan flag Jan Kara
2018-10-18 14:18 ` Johannes Thumshirn
2018-10-22 22:52 ` Omar Sandoval [this message]
2018-10-23 10:05 ` Jan Kara
2018-10-23 18:57 ` Omar Sandoval
2018-10-24 13:14 ` Jan Kara
2018-10-18 10:31 ` [PATCH 2/2] loop/007: Add test for oops during backing file verification Jan Kara
2018-10-18 14:19 ` Johannes Thumshirn
2018-10-22 22:55 ` Omar Sandoval
2018-10-25 21:18 ` [PATCH 0/2] blktests: New loop tests Omar Sandoval
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=20181022225255.GB10074@vader \
--to=osandov@osandov.com \
--cc=jack@suse.cz \
--cc=jthumshirn@suse.de \
--cc=linux-block@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