[LTP] [PATCH v2 1/2] lib: limit the size of tmpfs in LTP

Li Wang liwang@redhat.com
Thu Jul 8 04:50:14 CEST 2021


Cyril Hrubis <chrubis@suse.cz> wrote:


>
> > +static char *limit_tmpfs_mount_size(const char *mnt_data,
> > +                     char *buf, size_t buf_size, const char *fs_type)
> > +{
> > +     int fd;
> > +     uint64_t dev_size;
> > +
> > +     if (strcmp(fs_type, "tmpfs"))
> > +             return mnt_data;
> > +
> > +     fd = SAFE_OPEN(tdev.dev, O_RDONLY);
> > +     SAFE_IOCTL(fd, BLKGETSIZE64, &dev_size);
> > +     SAFE_CLOSE(fd);
>
> We can as well add size to the struct tst_device and fill it in when
> device is created, that would be a slightly cleaner solution.
>


That should be fine. But I'm afraid we have to change the return type
for many functions in tst_device.c, because currently most of them
only return a path to the test device. And that will affect more tests.

Or, maybe just create a function to get the device size and pass it
to tdev.size simply?

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210708/5ddf761e/attachment.htm>


More information about the ltp mailing list