简体   繁体   English

在 UBI 文件系统中将文件从源复制到目标

[英]copy file from source to destination in UBI file system

I want to copy file from source to destination.我想将文件从源复制到目标。 But in case of destination folder size is small compare to source file.但如果目标文件夹的大小与源文件相比较小。 It does not fail write, always return success and this behaviour I have observed in UBI file system only.它不会失败写入,总是返回成功,这种行为我只在 UBI 文件系统中观察到。

while ((size = fread(buffer, 1, BUFSIZ, source)) > 0)
{
    size_t size_2 = fwrite(buffer, 1, size, destination);
    if (size_2 != size)
    {
        retval = -1;
        break;
    }
}

In UBIFS supports write-back, In which file changes are cached and go to the flash later.在 UBIFS 中支持回写,其中文件更改被缓存并稍后转到闪存。 Any one know how to verify write status for this.任何人都知道如何为此验证写入状态。

You can use fsync to verify the write-back status.您可以使用 fsync 来验证回写状态。

To quote from the following source:引自以下来源:

transfers ("flushes") all modified in-core data of ... the file referred to by the file descriptor fd to the disk device (or other permanent storage device) so that all changed information can be retrieved even if the system crashes or is rebooted.将文件描述符 fd 所指文件的所有修改后的内核数据传输(“刷新”)到磁盘设备(或其他永久存储设备),以便即使系统崩溃或重新启动。 This includes writing through or flushing a disk cache if present这包括写入或刷新磁盘缓存(如果存在)

http://man7.org/linux/man-pages/man2/fdatasync.2.html http://man7.org/linux/man-pages/man2/fdatasync.2.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM