In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to solve the problem of linux using cp to report errors. The content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The first thing that occurred to me was that maybe ioctl could check the file. Unfortunately, I guessed wrong and took a look at the source code of cp. It turns out that if a file is running and another process is open to get write permission, the open itself will fail and return-1 ETXTBSY errno.
So why can cp-f work again? Because cp-f will first delete the target file (the file to be overwritten), and then put the source file rename as the target file name.
From the perspective of kernel code, when running a binary file
Sys_execve ()
Do_execve ()
Open_exec ()
Deny_write_access ()
The deny_write_access here subtracts the i_writecount member of the file corresponding to inode by 1, and usually the value of i_writecount becomes-1 (initially 0).
At this point, another process wants to open in write mode:
Do_sys_open ()
Do_filp_open ()
Path_openat ()
Do_last ()
Nameidata_to_filp ()
_ _ dentry_open ()
_ _ get_file_write_access ()
Get_write_access ()
Get_write_access will find that the i_writecount member of inode is negative, so directly return-ETXTBSY
The above content is how to solve the problem of linux using cp to report errors. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.