当前位置:网站首页>02 specific implementation of LS command
02 specific implementation of LS command
2022-07-04 04:08:00 【Blue wind 9】
Preface
// ha-ha Yesterday's was a little perfunctory , I can't say it's not a detail ?
ha-ha This command Should be linux Users Basically, I will use it ?
ha-ha Here we are mainly to glance at How does this command work
main Mainly parameter processing , Cycle through the paths Output the information of each path
print_dir It is mainly to traverse each under the current path Sub file ( clip ), The specific business is entrusted to gobble_file, Collect each Sub file ( clip ) Information about
gobble_file Mainly used lstat/stat Command to get each file ( clip ) Related metadata of
print_current_files Mainly output each Sub file ( clip ) Information about , Here, this involves the specific output format , We are here to ls -l For example
print_long_format The output of is common ll Processing of output , Output fmode, nlink, user, group, size, mtime, fileName
be based on linux-4.4.0 + coreutils-8.25
Debugging is command based "ls -l /"
main
What you can see is ls There is only one path behind "/"
Here is the call print_dir To output "/" Each of the following Sub file ( clip ) Information about

print_dir
be based on opendir, readdir And so on api Traverse "/" Each of the following Sub file ( clip )
call gobble_file To get each Sub file ( clip ) Related metadata of

gobble_file
adopt stat/lstat relevant api To get the current file ( clip ) Metadata information of

print_current_files
according to Output format Make different outputs , Here we are print_long_format

print_long_format
The function content is long , It's not finished here
Use buf towards stdout Output fmode, nlink
user, group Additional system calls are required to obtain uid, gid The corresponding name , Use it directly stdout Output
Use buf towards stdout Output size, mtime, fileName


ha-ha These built-in commands Is it not so mysterious ?
Of course Here is only the core context of analysis , Real implementation details There are also many designs
End
边栏推荐
- Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
- vim正确加区间注释
- Why is the probability of pod increasing after IPtable
- [Huawei cloud IOT] reading notes, "Internet of things: core technology and security of the Internet of things", Chapter 3 (I)
- 02 ls 命令的具体实现
- “软硬皆施”,助力建成新型云计算数据中心
- Myslq delete followed by limit
- Value transfer communication between components (parent to child, child to parent, brother component to value)
- [paddleseg source code reading] paddleseg custom data class
- 【愚公系列】2022年7月 Go教学课程 002-Go语言环境安装
猜你喜欢

Defensive programming skills

idea修改主体颜色

Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡

Mitsubishi M70 macro variable reading Mitsubishi M80 public variable acquisition Mitsubishi CNC variable reading acquisition Mitsubishi CNC remote tool compensation Mitsubishi machine tool online tool

拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。

Pytest multi process / multi thread execution test case

laravel admin里百度编辑器自定义路径和文件名
![Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure](/img/ba/c1d40de154344ccc9f2fd1dd4cb12f.png)
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure

Perf simple process for multithreaded profile

Katalon框架测试web(二十六)自动发邮件
随机推荐
Future源碼一觀-JUC系列
Msgraphmailbag - search only driveitems of file types
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类
Storage of MySQL database
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
[PaddleSeg 源码阅读] PaddleSeg Transform 的 Normalize操作
Detailed explanation of PPTC self recovery fuse
[paddleseg source code reading] paddleseg calculation dice
Apple submitted the new MAC model to the regulatory database before the spring conference
SDP中的SPA
The new data center helps speed up the construction of a digital economy with data as a key element
Sales management system of lightweight enterprises based on PHP
CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构
JVM family -- monitoring tools
Deep thinking on investment
How to dynamically cache components in Vue multi-level route nesting
Redis cluster uses Lua script. Lua script can also be used for different slots
Support the first triggered go ticker
Class summation, shortest row
Database SQL statement summary, continuous update