From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] libswap.c: Check free space with correct mnt path
Date: Sun, 3 Mar 2024 14:04:05 +0100 [thread overview]
Message-ID: <20240303130405.GA1856074@pevik> (raw)
In-Reply-To: <CAEemH2e_7sD==18K2174SnGcJWiA8B0Zco2GwHdavoBatXuAbQ@mail.gmail.com>
Hi Wei, Li,
> Hi Wei,
> Good catch!
Great, thanks, merged!
(Tested at least on intel.)
> Reviewed-by: Li Wang <liwang@redhat.com>
> On Fri, Mar 1, 2024 at 9:51 AM Wei Gao via ltp <ltp@lists.linux.it> wrote:
> > The tst_fs_has_free should check fs size of mnt point.
> > But current code check ".", that means check /tmp/LTP_xxx
> > instead of /tmp/LTP_xxx/mntpoint.
> > Also tst_fs_has_free's "size" parameter's type is unsigned int,
> > it will overflow if encounter big filesystem block size(such as Btrfs
> > can use 64k).
I would personally added this as separate previous patch, but kept as is.
...
> > +++ b/libs/libltpswap/libswap.c
> > @@ -137,6 +137,7 @@ int make_swapfile(const char *swapfile, int blocks,
> > int safe)
> > struct statvfs fs_info;
> > unsigned long blk_size, bs;
> > size_t pg_size = sysconf(_SC_PAGESIZE);
> > + char mnt_path[100];
> > if (statvfs(".", &fs_info) == -1)
> > return -1;
> > @@ -149,7 +150,8 @@ int make_swapfile(const char *swapfile, int blocks,
> > int safe)
> > else
> > bs = blk_size;
> > - if (!tst_fs_has_free(".", bs * blocks, TST_BYTES))
> > + sscanf(swapfile, "%[^/]", mnt_path);
Although this should never fail, I changed it to check return value:
- if (!tst_fs_has_free(".", bs * blocks, TST_BYTES))
+ if (sscanf(swapfile, "%[^/]", mnt_path) != 1)
+ tst_brk(TBROK, "sscanf failed");
And I'll ask Andrea Manzini to add SAFE_SSCANF() (easy hack).
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2024-03-03 13:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 1:50 [LTP] [PATCH v1] libswap.c: Check free space with correct mnt path Wei Gao via ltp
2024-03-01 4:14 ` Li Wang
2024-03-03 13:04 ` Petr Vorel [this message]
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=20240303130405.GA1856074@pevik \
--to=pvorel@suse.cz \
--cc=liwang@redhat.com \
--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.