精华内容
下载资源
问答
  • Linux系统调用fsync函数详解发布时间:2013-11-14 19:55:10 作者:佚名 我要评论Linux fsync函数主要用于将同步内存中所有已修改的文件数据到储存设备,多用于备份功能描述:同步内存中所有已修改的文件数据到储存...

    Linux系统调用fsync函数详解

    发布时间:2013-11-14 19:55:10   作者:佚名   text-message.png 我要评论

    Linux fsync函数主要用于将同步内存中所有已修改的文件数据到储存设备,多用于备份

    功能描述:

    同步内存中所有已修改的文件数据到储存设备。

    用法:

    #include

    int fsync(int fd);

    参数:

    fd:文件描述词。

    返回说明:

    成功执行时,返回0。失败返回-1,errno被设为以下的某个值

    EBADF: 文件描述词无效

    EIO : 读写的过程中发生错误

    EROFS, EINVAL:文件所在的文件系统不支持同步

    强制把系统缓存写入文件sync和fsync函数,, fflush和fsync的联系和区别2010-05-10 11:25传统的U N I X实现在内核中设有缓冲存储器,大多数磁盘I / O都通过缓存进行。当将数据写

    到文件上时,通常该数据先由内核复制到缓存中,如果该缓存尚未写满,则并不将其排入输出

    队列,而是等待其写满或者当内核需要重用该缓存以便存放其他磁盘块数据时,再将该缓存排

    入输出队列,然后待其到达队首时,才进行实际的I / O操作。这种输出方式被称之为延迟写

    (delayed write)(Bach 〔1 9 8 6〕第3章详细讨论了延迟写)。延迟写减少了磁盘读写次数,但是

    第4章文件和目录8 7

    下载

    却降低了文件内容的更新速度,使得欲写到文件中的数据在一段时间内并没有写到磁盘上。当

    系统发生故障时,这种延迟可能造成文件更新内容的丢失。为了保证磁盘上实际文件系统与缓

    存中内容的一致性,U N I X系统提供了s y n c和f s y n c两个系统调用函数。

    #include

    void sync(void);

    int fsync(intf i l e d e s) ;

    返回:若成功则为0,若出错则为-1

    s y n c只是将所有修改过的块的缓存排入写队列,然后就返回,它并不等待实际I / O操作结束。

    系统精灵进程(通常称为u p d a t e )一般每隔3 0秒调用一次s y n c函数。这就保证了定期刷新内

    核的块缓存。命令s y n c ( 1 )也调用s y n c函数。

    函数f s y n c只引用单个文件(由文件描述符f i l e d e s指定),它等待I / O结束,然后返回。f s y n c可

    用于数据库这样的应用程序,它确保修改过的块立即写到磁盘上。比较一下f s y n c和O _ S Y N C标

    志(见3 . 1 3节)。当调用f s y n c时,它更新文件的内容,而对于O _ S Y N C,则每次对文件调用w r i t e

    函数时就更新文件的内容。

    fflush和fsync的联系和区别

    [zz ] http://blog.chinaunix.net/u2/73874/showart_1421917.html

    1.提供者fflush是libc.a中提供的方法,fsync是系统提供的系统调用。2.原形fflush接受一个参数FILE *.fflush(FILE *);fsync接受的时一个Int型的文件描述符。fsync(int fd);3.功能fflush:是把C库中的缓冲调用write函数写到磁盘[其实是写到内核的缓冲区]。fsync:是把内核缓冲刷到磁盘上。

    c库缓冲-----fflush---------〉内核缓冲--------fsync-----〉磁盘

    再转一篇英文的

    Write-back support

    UBIFS supports write-back, which means that file changes do not go to the flash media straight away, but they are cached and go to the flash later, when it is absolutely necessary. This helps to greatly reduce the amount of I/O which results in better performance. Write-back caching is a standard technique which is used by most file systems like ext3 or XFS.

    In contrast, JFFS2 does not have write-back support and all the JFFS2 file system changes go the flash synchronously. Well, this is not completely true and JFFS2 does have a small buffer of a NAND page size (if the underlying flash is NAND). This buffer contains last written data and is flushed once it is full. However, because the amount of cached data are very small, JFFS2 is very close to a synchronous file system.

    Write-back support requires the application programmers to take extra care about synchronizing important files in time. Otherwise the files may corrupt or disappear in case of power-cuts, which happens very often in many embedded devices. Let's take a glimpse at Linux manual pages:

    $ man 2 write

    ....

    NOTES

    A successful return from write() does not make any guarantee that data

    has been committed to disk. In fact, on some buggy implementations, it

    does not even guarantee that space has successfully been reserved for

    the data. The only way to be sure is to call fsync(2) after you are

    done writing all your data.

    ...

    This is true for UBIFS (except of the "some buggy implementations" part, because UBIFS does reserves space for cached dirty data). This is also true for JFFS2, as well as for any other Linux file system.

    However, some (perhaps not very good) user-space programmers do not take write-back into account. They do not read manual pages carefully. When such applications are used in embedded systems which run JFFS2 - they work fine, because JFFS2 is almost synchronous. Of course, the applications are buggy, but they appear to work well enough with JFFS2. But the bugs show up when UBIFS is used instead. Please, be careful and check/test your applications with respect to power cut tolerance if you switch from JFFS2 to UBIFS. The following is a list of useful hints and advices.

    If you want to switch into synchronous mode, use the -o sync option when mounting UBIFS; however, the file system performance will drop - be careful; Also remember that UBIFS mounted in synchronous mode provides less guarantees than JFFS2 - refer this section for details.

    Always keep in mind the above statement from the manual pages and run fsync() for all important files you change; of course, there is no need to synchronize "throw-away" temporary files; Just think how important is the file data and decide; and do not use fsync() unnecessarily, because this will hit the performance;

    If you want to be more accurate, you may use fdatasync(), in which cases only data changes will be flushed, but not inode meta-data changes (e.g., "mtime" or permissions); this might be more optimal than using fsync() if the synchronization is done often, e.g., in a loop; otherwise just stick with fsync();

    In shell, the sync command may be used, but it synchronizes whole file system which might be not very optimal; and there is a similar libc sync() function;

    You may use the O_SYNC flag of the open() call; this will make sure all the data (but not meta-data) changes go to the media before the write() operation returns; but in general, it is better to use fsync(), because O_SYNC makes each write to be synchronous, while fsync() allows to accumulate many writes and synchronize them at once;

    It is possible to make certain inodes to be synchronous by default by setting the "sync" inode flag; in a shell, the chattr +S command may be used; in C programs, use the FS_IOC_SETFLAGS ioctl command; Note, the mkfs.ubifs tool checks for the "sync" flag in the original FS tree, so the synchronous files in the original FS tree will be synchronous in the resulting UBIFS image.

    Let us stress that the above items are true for any Linux file system, including JFFS2.

    fsync() may be called for directories - it synchronizes the directory inode meta-data. The "sync" flag may also be set for directories to make the directory inode synchronous. But the flag is inherited, which means all new children of this directory will also have this flag. New files and sub-directories of this directory will also be synchronous, and their children, and so forth. This feature is very useful if one needs to create a whole sub-tree of synchronous files and directories, or to make all new children of some directory to be synchronous by default (e.g., /etc).

    The fdatasync() call for directories is "no-op" in UBIFS and all UBIFS operations which change directory entries are synchronous. However, you should not assume this for portability (e.g., this is not true for ext2). Similarly, the "dirsync" inode flag has no effect in UBIFS.

    The functions mentioned above work on file-descriptors, not on streams (FILE *). To synchronize a stream, you should first get its file descriptor using the fileno() libc function, then flush the stream using fflush(), and then synchronize the file using fsync() or fdatasync(). You may use other synchronization methods, but remember to flush the stream before synchronizing the file. The fflush() function flushes the libc-level buffers, while sync(), fsync(), etc flush kernel-level buffers.

    Please, refer this FAQ entry for information about how to atomically update the contents of a file. Also, the Theodore Tso's article is a good reading.

    Write-back knobs in Linux

    Linux has several knobs in "/proc/sys/vm" which you may use to tune write-back. The knobs are global, so they affect all file-systems. Please, refer the "Documentation/sysctl/vm.txt" file fore more information. The file may be found in the Linux kernel source tree. Below are interesting knobs described in UBIFS context and in a simplified form.

    dirty_writeback_centisecs - how often the Linux periodic write-back thread wakes up and writes out dirty data. This is a mechanism which makes sure all dirty data hits the media at some point.

    dirty_expire_centisecs - dirty data expire period. This is maximum time data may stay dirty. After this period of time it will be written back by the Linux periodic write-back thread. IOW, the periodic write-back thread wakes up every "dirty_writeback_centisecs" centi-seconds and synchronizes data which was dirtied "dirty_expire_centisecs" centi-seconds ago.

    dirty_background_ratio - maximum amount of dirty data in percent of total memory. When the amount of dirty data becomes larger, the periodic write-back thread starts synchronizing it until it becomes smaller. Even non-expired data will be synchronized. This may be used to set a "soft" limit for the amount of dirty data in the system.

    dirty_ratio - maximum amount of dirty data at which writers will first synchronize the existing dirty data before adding more. IOW, this is a "hard" limit of the amount of dirty data in the system.

    Note, UBIFS additionally has small write-buffers which are synchronized every 3-5 seconds. This means that most of the dirty data are delayed by dirty_expire_centisecs centi-seconds, but the last few KiB are additionally delayed by 3-5 seconds.

    UBIFS write-buffer

    UBIFS is asynchronous file-system (read this section for more information). As other Linux file-system, it utilizes the page cache. The page cache is a generic Linux memory-management mechanism. It may be very large and cache a lot of data. When you write to a file, the data are written to the page cache, marked as dirty, and the write returns (unless the file is synchronous). Later the data are written-back.

    Write-buffer is an additional UBIFS buffer, which is implemented inside UBIFS, and it sits between the page cache and the flash. This means that write-back actually writes to the write-buffer, not directly to the flash.

    The write-buffer is designated to speed-up UBIFS on NAND flashes. NAND flashes consist of NAND pages, which are usually 512, 2KiB or 4KiB in size. NAND page is the minimal read/write unit of NAND flash (see this section).

    Write-buffer size is equivalent to NAND page size (so it is tiny comparing to the page cache). It's purpose is to accumulate small writes, and write full NAND pages instead of partially filled. Indeed, imagine we have to write 4 512-byte nodes with half a second interval, and NAND page size is 2KiB. Without write-buffer we would have to write 4 NAND pages and waste 6KiB of flash space, while write-buffer allows us to write only once and waste nothing. This means we write less, we create less dirty space so UBIFS garbage collector will have to do less work, we save power.

    Well, the example shows an ideal situation, and even with the write-buffer we may waste space, for example in case of synchronous I/O, or if the data arrives with long time intervals. This is because the write-buffer has an associated timer, which flushes it every 3-5 seconds, even if it isn't full. We do this for data integrity reasons.

    Of course, when UBIFS has to write a lot of data, it does not use write buffer. Only the last part of the data which is smaller than the NAND page ends up in the write-buffer and waits more for data, until it is flushed by the timer.

    The write-buffer implementation is a little more complex, and we actually have several of them - one for each journal head. But this does not change the basic idea behind the write-buffer.

    Few notes with regards to synchronization:

    "sync()" also synchronizes all write-buffers;

    "fsync(fd)" also synchronizes all write-buffers which contain pieces of "fd";

    synchronous files, as well as files opened with "O_SYNC", bypass write-buffers, so the I/O is indeed synchronous for this files;

    write-buffers are also bypassed if the file-system is mounted with the "-o sync" mount option.

    Take into account that write-buffers delay the data synchronization timeout defined by "dirty_expire_centisecs" (see here) by 3-5 seconds. However, since write-buffers are small, only few data are delayed.

    UBIFS in synchronous mode vs JFFS2

    When UBIFS is mounted in synchronous mode (-o sync mount options) - all file system operations become synchronous. This means that all data are written to flash before the file-system operations return.

    For example, if you write 10MiB of data to a file f.dat using the write() call, and UBIFS is in synchronous mode, then UBIFS guarantees that all 10MiB of data and the meta-data (file size and date changes) will reach the flash media before write() returns. And if a power cut happens after the write() call returns, the file will contain the written data.

    The same is true for situations when f.dat has was opened with O_SYNC or has the sync flag (see man 2 chattr).

    It is well-known that the JFFS2 file-system is synchronous (except a small write-buffer). However, UBIFS in synchronous mode is not the same as JFFS2 and provides somewhat less guarantees that JFFS2 does with respect to sudden power cuts.

    In JFFS2 all the meta-data (like inode atime/mtime/ctime, inode size, UID/GID, etc) are stored in the data node headers. Data nodes carry 4KiB of (compressed) data. This means that the meta-data information is duplicated in many places, but this also means that every time JFFS2 writes a data node to the flash media, it updates inode size as well. So when JFFS2 mounts it scans the flash media, finds the latest data node, and fetches the inode size from there.

    In practice this means that JFFS2 will write these 10MiB of data sequentially, from the beginning to the end. And if you have a power cut, you will just lose some amount of data at the end of the inode. For example, if JFFS2 starts writing those 10MiB of data, write 5MiB, and a power cut happens, you will end up with a 5MiB f.dat file. You lose only the last 5MiB.

    Things are a little bit more complex in case of UBIFS, where data are stored in data nodes and meta-data are stored in (separate) inode nodes. The meta-data are not duplicated in each data node, like in JFFS2. UBIFS never writes data nodes beyond the on-flash inode size. If it has to write a data node and the data node is beyond the on-flash inode size (the in-memory inode has up-to-data size, but it is dirty and was not flushed yet), then UBIFS first writes the inode to the media, and then it starts writing the data. And if you have an interrupt, you lose data nodes and you have holes (or old data nodes, if you are overwriting). Lets consider an example.

    User creates an empty file f.dat. The file is synchronous, or UBIFS is mounted in synchronous mode. User calls the write() function with a 10MiB buffer.

    The kernel first copies all 10MiB of the data to the page cache. Inode size is changed to 10MiB as well and the inode is marked as dirty. Nothing has been written to the flash media so far. If a power cut happens at this point, the user will end up with an empty f.dat file.

    UBIFS sees that the I/O has to be synchronous, and starts synchronizing the inode. First of all, it writes the inode node to the flash media. If a power cut happens at this moment, the user will end up with a 10MiB file which contains no data (hole), and if he read this file, he will get 10MiB of zeroes.

    UBIFS starts writing the data. If a power cut happens at this point, the user will end up with a 10MiB file containing a hole at the end.

    Note, if the I/O was not synchronous, UBIFS would skip the last step and would just return. And the actual write-back would then happen in back-ground. But power cuts during write-back could anyway lead to files with holes at the end.

    Thus, synchronous I/O in UBIFS provides less guarantees than JFFS2 I/O - UBIFS has an effect of holes at the end of files. In ideal world applications should not assume anything about the contents of files which were not synchronized before a power-cut has happened. And "mainstream" file-systems like ext3 do not provide JFSS2-like guarantees.

    However, UBIFS is sometimes used as a JFFS2 replacement and people may want it to behave the same way as JFFS2 if it is mounted synchronously. This is doable, but needs some non-trivial development, so this was not implemented so far. On the other hand, there was no strong demand. You may implement this as an exercise, or you may try to convince UBIFS authors to do this.

    Synchronization exceptions for buggy applications

    As this section describes, UBIFS is an asynchronous file-system, and applications should synchronize their files whenever it is required. The same applies to most Linux file-systems, e.g. XFS.

    However, many applications ignore this and do not synchronize files properly. And there was a huge war between user-space and kernel developers related to ext4 delayed allocation feature. Please, see the Theodore Tso's blog post. More information may be found in this LWN article.

    In short, the flame war was about 2 cases. The first case was about the atomic re-name, where many user-space programs did not synchronize the copy before re-naming it. The second case was about applications which truncate files, then change them. There was no final agreement, but the "we cannot ignore the real world" argument found ext4 developers' understanding, and there were 2 ext4 changes which help both problems.

    Roughly speaking, the first change made ext4 synchronize files on close if they were previously truncated. This was a hack from file-system point of view, but it "fixed" applications which truncate files, write new contents, and close the files without synchronizing them.

    The second change made ext4 synchronize the renamed file.

    Well, this is not exactly correct description, because ext4 does not write the files synchronously, but actually initiates asynchronous write-out of the files, so the performance hit is not very high. For the truncation case this means that the file is synchronized soon after it is closed. For the re-name case this means that ext4 writes data before it writes the re-name meta-data.

    However, the application writers should never rely on these things, because this is not portable. Instead, they should properly synchronize files. The ext4 fixes were because there were many broken user-space applications in the wild already.

    We have plans to implement these features in UBIFS, but this has not been done yet. The problem is that UBI/MTD are fully synchronous and we cannot initiate asynchronous write-out, so we'd have to synchronously write files on close/rename, which is slow. So implementing these features would require implementing asynchronous I/O in UBI, which is a big job. But feel free to do this :-).

    相关文章

    fe68436a2b980756ca47e14445394433.png

    deepin20怎么使用画板打开图片?deepin20系统想要打开图片,该怎么使用画板打开图片呢?下面我们就来看看deepin画板打开图片的两种方法,需要的朋友可以参考下2020-10-03

    5a9eb4ea3acddc702d2e89eb26f7deee.png

    deepin20默认浏览器怎么设置?eepin20系统想要设置默认浏览器,该怎么设置呢?下面我们就来看看deepin添加默认浏览器的技巧,需要的朋友可以参考下2020-10-03

    7c8420c1cf3d471f50480cddc1b98b14.png

    deepin系统怎么设置屏幕分辨率?deepin系统不是很清晰,想要设置分辨率,该怎么设置分辨率呢?下面我们就来看看deepin分辨率的设置方法,需要的朋友可以参考下2020-09-29

    f702131bb90ba61557ec5f9df225f61b.png

    deepin20系统字体怎么设置?deepin20系统字体太小,想要设置大一些,该怎么调整字体的大小呢?下面我们就来看看deepin终端字体大小的设置方法,需要的朋友可以参考下2020-09-27

    94d6fbfa7d33e532321e2f247ea2706b.png

    鼠标怎么设置为左手?deepin20系统中,默认鼠标是右手模式,但是用习惯了左手,想要设置为左手模式,该怎么操作呢?下面我们就来看看deepin20左手鼠标设置方法,需要的朋友2020-09-25

    570b0c0d6c7992ed9a6ef2fdb1ae3c0e.png

    cpu主频怎么看?想要查看cpu主频,在windows系统下很方便查看,那么deepin20系统该怎么操作呢?我们今天就来介绍两种deepin20查看CPU主频的技巧,需要的朋友可以参考下2020-09-24

    0c271988b7bac465b24aca421ec51e6d.png

    deepin20网关地址怎么设置?deepin20系统想要设置网关地址,该怎么设置呢?下面我们就来看看deepin网关地址的修改方法,需要的朋友可以参考下2020-09-23

    5210f4759794a081ee3f965321e68169.png

    deepin20怎么设置图标的排列方式?deepin20中想要设置图标的显示方式,有列表视图和图标视图,该怎么设置为图标视图呢?下面我们就来看看deepin图标视图设置方法,需要的朋2020-09-23

    d52c34e324728940d7f6378ea363c1e4.png

    deepin20窗口最小化魔灯效果怎么设置?deepin20系统窗口最小化是有一些特效的,想要添加魔灯效果,该怎么实现呢?下面我们就来看看详细的教程,需要的朋友可以参考下2020-09-22

    56f97b5b1aa9ffa276fb6259a6234398.png

    deepin20任务栏透明度怎么设置?电脑任务栏透明度是可以调节的,该怎么调节呢?下面我们就来看看deepin调整任务栏透明度的技巧,需要的朋友可以参考下2020-09-21

    最新评论

    展开全文
  • 所以,互斥锁实质上是操作系统提供的一把“建议锁”(又称“协同锁”),建议程序中有多线程访问共享资源的时候使用该机制。但,并没有强制限定。 因此,即使有了mutex,如果有线程不按规则来访问数据,依然会造成...
  • 这些问题很琐碎,不具备任何技术含量,纯属耽误时间,这也是linux系统的通病,花里胡哨,故弄玄虚。为了减少初学者在这种无意义的事情上浪费大量的时间,本文对这个问题提供一点解决方案,这些方案都是在Ubuntu18.04...

    在ubuntu下代码编译通过的情况下,经常出现运行时加载动态库出错的情况。这些问题很琐碎,不具备任何技术含量,纯属耽误时间,这也是linux系统的通病,花里胡哨,故弄玄虚。

    为了减少初学者在这种无意义的事情上浪费大量的时间,本文对这个问题提供一点解决方案,这些方案都是在Ubuntu18.04上测试过的,希望对需要者有所帮助。

    这里使用的是最小化的代码,主程序是mytest,其运行时需要调用libtest.so, 成功调用后输出信息:Hello Shared Library!

    否则会抱怨找不到动态库。

    本文的工作目录为/home/eric/dlltest

    471f47b8ef9e76a93e0f9ae7a7633318.png

    error while loading shared libraries:libtest.so: cannot open shared object file: No such file or directory

    这就对了,符合本文的预期,libtest.so已经被移除了,所以会报错。

    下面将libtest.so拷贝回来。

    有:

    a2c052d6e8cb5db89873c6e960237cb6.png

    可见这样mytest就找到了动态库libtest.so。

    bf42090b91707f7c0e2a809ebada582d.png

    再次将libtest.so移动到/home/eric/lib/下面,有:

    5c24f3b31d5bc19b97f57d2a86daff74.png

    这时候,

    958fb89862bbb5046df0396c389c960a.png

    dlltest下面只有mytest执行文件,继续测试有:

    f7cf6997304f7f35b323fe974a1d6877.png

    错误继续出现,这样就对了。下面想办法能够让mytest程序能够找到动态库libtest.so。

    第一种方法:

    使用

    5fb6a6af9576be241cc5a0756d9d2292.png

    可以看到,动态库找到了,然而这种方法关闭了窗口之后就没效果了。

    935136db1996b81075bed102baa370a8.png

    重启命令窗口后问题继续出现,

    这时候需要

    第二种方法,修改.bashrc文件

    进入到/home/eric下(eric是本文在ubuntu上的用户名)

    7f44915d454dbc3ce000c185006127c5.png

    afbd0805f12ca3ccffc6e73c0b038716.png

    在.bashrc文件末尾加入:

    export LD_LIBRARY_PATH=/home/eric/lib:$LD_LIBRARY_PATH

    f3fb4eb5ea55bd92c5b1ffe918cf64d7.png

    也就是上图第121行,保存退出后,运行source .bashrc

    f7d24618050eccfa267a25b39487da7b.png

    可见/home/eric/lib 已经在库路径里面了。

    这是进入到/home/eric/dlltest目录:

    c0f20884400ea5673d61a5da87e7414c.png

    可见,这次动态库路径是对的,为了保险起见,关闭窗口,重新打开,有:

    9a443bc0708fdb4535c6bf20c6aa14a7.png

    可见还是可以找到的。

    下面将export LD_LIBRARY_PATH=/home/eric/lib:$LD_LIBRARY_PATH 从/home/eric/.bashrc文件中注释掉。

    06f7a9e5fa0959e093b451dece63ae3e.png

    e9bfa61ad5b1bb914fcf78e598ce9ba4.png

    可见还是找的到动态库,这不科学!

    937e1931b897d2d4b9f9d7a6e33aff5b.png

    查看库路径果然/home/eric/lib还在,这时候需要运行下source .bashrc,可以看到库变量改变了。

    85e401a2f19abf244ccbfefafa040582.png

    不过虽然是库变量改变了,但是还是系统找得到动态库libtest.so,只好关闭窗口重启了:

    59ae123132284d7d80c66274b6abf5ba.png

    这次是真的找不到了。

    linux系统下就是经常发生这种非常微妙的小插曲,当你以为搞定了,实际上却是错误的结论,好在本文用了一个最小出错模型,有大量的时间可以耗下去,如果在生产环境,这种代价是承受不起的。

    这样第二种方法也测试成功了。下面介绍第三种方法。

    第三种方法,修改/etc/ld.so.conf文件

    本文的/etc/ld.so.conf内容为:

    41b38597669d28b1d4cc544fac0f6244.png

    加上路径/home/eric/lib/

    有:

    f452f2b16db2d83cb74ba4be7f819c40.png

    修改后保存。

    46a70391f94c8f55dcba9ebf4da6b6bf.png

    继续测试mytest,可见还是找不到库。

    这是需要运行sudo ldconfig:

    373960104e51b0cafd5542252ec71b47.png

    本文运行的当前目录是/home/eric/dlltest

    可见sudo ldconfig命令不挑当前目录。

    为了保险起见,关闭窗口,重新启动:

    b7abe4d9ed8970f683ca2b827c7044ee.png

    可见还是可以找得到的,说明此方法可行。

    继续修改etc/ld.so.conf文件,删除路径/home/eric/lib/,并运行sudo ldconfig等有:

    1dbe5a8d043eed5d28a52dd41ab3c9bd.png

    说明又找不到了,好的,符合预期,重启窗口试一下,虽然不大有可能出现反常,但是怕了,必须验证!

    fa46a9eb20d3e9419bea8f5aff6129b6.png

    还是没找到,说明的确第三种方法是起作用的。

    下面介绍第四种方法:

    第四种:在/etc/ld.so.conf.d/目录下添加youtest.conf文件

    86e361babeafb1d3a5fffacb758ea30f.png

    bfb6958eaff6456f2e0fcc38190bf769.png

    文件内容为/home/eric/lib/

    也就是动态库libtest.so的所在路径。

    0cdf131de10bc3fa926e4af7a7ab09d7.png

    可以看到youtest.conf文件产生了。

    这是运行mytest测试一下:

    a07a105e314c315aa267f5e6fc7a4045.png

    没找到,这符合预期,还没有使用sudo ldconfig命令

    2854441830547271c9445f05445b1569.png

    可见,这次文件youtest.conf起作用了,文件名youtest.conf是为了避嫌,也就是这个可以和mytest不一样,当然后缀名是需要.conf就行。

    再次重启窗口,

    074af2b196d7f34c7144dcaaeb9d65bd.png

    可见还是可以找得到动态库。

    说明这种方法也是成功的。

    综上所述,本文介绍了找动态库的四种方法,也许方法可能会有千千万万种,但是本文不感兴趣,有了这几种方法后,初学者容易有获得感和幸福感,从而有进一步学习的勇气和道路自信,其它的方法都可以触类旁通,进而获得更大意义上的自由。

    应该说,本文的环境是WSL下的ubuntu18.04,在其它系统上可能会产生一些细微的差异,需要灵活运用。

    后面有时间的话还会有些类似的文章,扫清这种没有任何技术含量的学习障碍,从而使初学者能够将有限的时间放到有价值的事情上去。

    展开全文
  • linux内核 0.11版本源码 带中文注释

    热门讨论 2009-08-31 15:10:21
    // Linux系统调用中断0x80。该中断是所有系统调用的 // 入口。该条语句实际上是int fork()创建进程系统调用。 // syscall0 名称中最后的0 表示无参数,1 表示1 个参数。 static inline _syscall0 (int, pause...
  • dir 查看文件,参数:/Q显示文件及目录属系统哪个用户,/T:C显示文件创建时间,/T:A显示文件上次被访问时间,/T:W上次被修改时间 date /t 、 time /t 使用此参数即“DATE/T”、“TIME/T”将只显示当前日期和时间,...
  • 只需要在配置中心指定文章系统安装目录即可调用。此调用方式,是直接读取相关数据库显示,完全独立开,不需要生成文件啥的。指定好目录就可以自动读取数据库。也可以自由安装到任意目录,可以任意更换模板。并且可以...
  • 系统设计和开发过程中,要充分考虑系统当前和将来可能承受的工作量,使系统的处理能力和响应时间能够满足信息处理的需求。 2、 系统的开放性和系统的可扩充性:系统在开发过程中,应该充分考虑以后的可扩充性。...
  • d) 能调用Linux系统中的Web浏览器(如mozilla)正确显示index.html页面。 2. myWebServer a) 能接受WEB浏览器的连接请求; b) 支持HTTP的GET消息,并正确处理该消息; c) 只支持静态网页请求(即只支持html页面请求...
  • 1) 修改在静态编译的DLL中调用其它DLL失败的BUG 2) 修改静态编译后“选择列表框”在“单选”属性为真时不显示项目内容的BUG 3) 修改核心库中“播放音乐”命令在没有声卡或声卡被禁用时未正确释放资源的BUG 4) ...
  • 淘客帝国破解版

    2012-02-01 12:54:55
    配合该调用系统,增加了一套单类别模板,可以用来调用单类别,或调用单店铺。 后台配置中心-高级设置里,增加了地区过滤字段。 首页综合配置增加了单独的排序设置。 针对单类别模板,首页综合配置内增加了卖家昵称...
  • 只需要在配置中心指定文章系统安装目录即可调用。此调用方式,是直接读取相关数据库显示,完全独立开,不需要生成文件啥的。指定好目录就可以自动读取数据库。也可以自由安装到任意目录,可以任意更换模板。并且可以...
  • pub类库

    2007-01-25 16:42:08
    就我遇到的情况,大部分则为操作失败调用的流程一般都要中止的。 这个判断也是比较难下的。放在一个局部,异常可能导致操作中止;但放在更上一层,则异常又可能是正确程序流程处理。 bug的反馈和修改支持 ...
  • 处于运行的作业会被系统监控,此处显示被监控的作业的监控信息,包括总作业任务数、总执行成功次数、总执行失败次数以及每个作业的成功次数和失败次数。查看详情页面还可以查看每次执行的日志及执行时间,日志还可...
  • 函数实战与常用数据结构函数的两种类型函数的本质再分析函数地址切换切换功能ifelse配合地址筛选函数收费函数调用过程函数基本小结return小结位置参数与默认参数混合参数填充混合填充错误情况lambda匿名函数可变长...
  • 只需要在配置中心指定文章系统安装目录即可调用。此调用方式,是直接读取相关数据库显示,完全独立开,不需要生成文件啥的。指定好目录就可以自动读取数据库。也可以自由安装到任意目录,可以任意更换模板。并且可以...
  • 设置缓存开关:用户可自己选择开启或关闭缓存功能,以及过期时间,自动删除过期的缓存! 后台配置分类:可自定义导航以及左栏分类,填写分类名称和对应分类ID即可! 蜘蛛屏蔽功能:可以选择禁用一些蜘蛛。 伪原创...
  • 淘客帝国v5.20破解版稳定官方原版

    热门讨论 2012-01-19 10:41:21
    设置缓存开关:用户可自己选择开启或关闭缓存功能,以及过期时间,自动删除过期的缓存! 后台配置分类:可自定义导航以及左栏分类,填写分类名称和对应分类ID即可! 蜘蛛屏蔽功能:可以选择禁用一些蜘蛛。 伪原创...
  • 淘客帝国5.21

    2012-12-25 12:12:04
    设置缓存开关:用户可自己选择开启或关闭缓存功能,以及过期时间,自动删除过期的缓存! 后台配置分类:可自定义导航以及左栏分类,填写分类名称和对应分类ID即可! 蜘蛛屏蔽功能:可以选择禁用一些蜘蛛。 伪原创...
  • 设置缓存开关:用户可自己选择开启或关闭缓存功能,以及过期时间,自动删除过期的缓存! 后台配置分类:可自定义导航以及左栏分类,填写分类名称和对应分类ID即可! 蜘蛛屏蔽功能:可以选择禁用一些蜘蛛。 伪原创...
  • 设置缓存开关:用户可自己选择开启或关闭缓存功能,以及过期时间,自动删除过期的缓存! 后台配置分类:可自定义导航以及左栏分类,填写分类名称和对应分类ID即可! 蜘蛛屏蔽功能:可以选择禁用一些蜘蛛。 伪原创...
  • 店盟淘客程序

    2013-04-07 22:38:41
    只需要在配置中心指定文章系统安装目录即可调用。此调用方式,是直接读取相关数据库显示,完全独立开,不需要生成文件啥的。指定好目录就可以自动读取数据库。也可以自由安装到任意目录,可以任意更换模板。并且可以...
  • 多奥淘宝客2012最新版

    2012-02-26 01:21:53
    只需要在配置中心指定文章系统安装目录即可调用。此调用方式,是直接读取相关数据库显示,完全独立开,不需要生成文件啥的。指定好目录就可以自动读取数据库。也可以自由安装到任意目录,可以任意更换模板。并且可以...
  • * 增加名站导航切换栏,可以在后台修改调用网址,如“常用软件”,“热门游戏”之类; * 增加天气预报的定制功能,并移至天气处可展开未来三天的天气预报; * 增加程序升级提醒,方便站长获得官方升级信息 * ...
  • * 增加名站导航切换栏,可以在后台修改调用网址,如“常用软件”,“热门游戏”之类; * 增加天气预报的定制功能,并移至天气处可展开未来三天的天气预报; * 增加程序升级提醒,方便站长获得官方升级信息 * ...
  • Loadrunner报错日志

    2014-10-24 15:12:34
    2、如果方法一操作后没有变化,此时需要去查看服务器操作系统中是否对连接数做了限制,AIX下可以直接vi文件limits修改其中的连接限制数、端口数,还有tcp连接等待时间间隔大小,wiodows类似,只不过windows修改...
  • 支持所有windows操作系统+linux操作系统和其他操作系统。 3.2 效果图 4 可视化大屏电子看板系统 4.1 功能特点 采用分层设计,整体总共分三级界面,一级界面是整体布局,二级界面是单个功能模块,三级界面是...
  • vc++ 开发实例源码包

    2014-12-16 11:25:17
    头开始播放 | 显示时间 | | | ---开始和暂停 ----------- 下一曲------ -------------------------------------- Linux内核完全注释附 如题,我没看。 MFC+消息循环贴图---金山毒霸界面 自绘控件实现。 MFC...

空空如也

空空如也

1 2 3 4
收藏数 65
精华内容 26
关键字:

linux调用修改系统时间失败

linux 订阅