<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 8, 2021 at 10:50 AM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-size:small">Cyril Hrubis <<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>> wrote:<br></div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
> +static char *limit_tmpfs_mount_size(const char *mnt_data,<br>
> + char *buf, size_t buf_size, const char *fs_type)<br>
> +{<br>
> + int fd;<br>
> + uint64_t dev_size;<br>
> +<br>
> + if (strcmp(fs_type, "tmpfs"))<br>
> + return mnt_data;<br>
> +<br>
> + fd = SAFE_OPEN(<a href="http://tdev.dev" rel="noreferrer" target="_blank">tdev.dev</a>, O_RDONLY);<br>
> + SAFE_IOCTL(fd, BLKGETSIZE64, &dev_size);<br>
> + SAFE_CLOSE(fd);<br>
<br>
We can as well add size to the struct tst_device and fill it in when<br>
device is created, that would be a slightly cleaner solution.<br></blockquote><div><br></div><div><br></div><div style="font-size:small">That should be fine. But I'm afraid we have to change the return type</div><div style="font-size:small">for many functions in tst_device.c, because currently most of them</div><div style="font-size:small">only return a path to the test device. And that will affect more tests.</div><div style="font-size:small"></div><div style="font-size:small"><br></div><div style="font-size:small">Or, maybe just create a function to get the device size and pass it</div><div style="font-size:small">to tdev.size simply?</div></div></div></blockquote><div> <br></div><div><div class="gmail_default" style="font-size:small">With adding new field 'size' in struct tst_device, I'm also planning</div><div class="gmail_default" style="font-size:small">to extract that from tst_acquire_device__ and export it as a global</div><div class="gmail_default" style="font-size:small">function: </div></div></div><div class="gmail_default" style="font-size:small"> uint64_t tst_get_device_size(const char *dev_path);<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">then reuse of it to get block device size in more places, like:</div><div class="gmail_default" style="font-size:small"> tdev.size = tst_get_device_size(<a href="http://tdev.dev">tdev.dev</a>); <-- in prepare_device</div><div class="gmail_default" style="font-size:small">and</div><div class="gmail_default" style="font-size:small"> ltp_dev_size = tst_get_device_size(dev); <-- in tst_acquire_device__</div><div class="gmail_default" style="font-size:small"></div><div><div class="gmail_default" style="font-size:small">That would keep most of the function API no change and save</div><div class="gmail_default" style="font-size:small">the tdev.size. Is this way OK, or any else?</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>