mv()在阅读时 [英] mv() while reading

查看:206
本文介绍了mv()在阅读时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux ext3文件系统上,如果在读取文件时在同一个文件(文件描述符)上调用mv(),会发生什么?这实际上是一个考试问题,我只能说如下:


  1. CPU陷阱操作系统用于中断处理


请注意,如果操作系统人员可以帮助我,请:D

解决方案

Linux重命名手册页:



这解释了大部分细节。

 如果一个或多个进程在最后一个链接被删除时打开文件,
在重命名()返回之前,该链接将被删除,但删除
文件内容应为推迟到所有对文件的引用关闭。


on Linux ext3 filesystem, what happens if mv() is called on the same file (file descriptor) while reading the file? It is actually an exam question and I can only say something like:

  1. CPU traps OS for interrupt handling
  2. etc, etc.

I would appreciate if OS guys out there can help me out, please :D

解决方案

Linux rename man page:

That explains most of the details of this.

If one or more processes have the file open when the last link is removed,
the link shall be removed before rename() returns, but the removal of the
file contents shall be postponed until all references to the file are closed. 

这篇关于mv()在阅读时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆