当前位置:网站首页>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
边栏推荐
猜你喜欢
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
JVM family -- monitoring tools
还原窗口位置的微妙之处
Detailed explanation of PPTC self recovery fuse
JVM family -- heap analysis
Global exposure and roller shutter exposure of industrial cameras
mysql数据库的存储
*. No main manifest attribute in jar
基于PHP的轻量企业销售管理系统
随机推荐
Katalon框架测试web(二十一)获取元素属性断言
Redis cluster view the slots of each node
LevelDB源码解读-SkipList
SDP中的SPA
基于PHP的轻量企业销售管理系统
A review of reverse reinforcement learning at Virginia Tech (VT)
Graduation summary
1289_FreeRTOS中vTaskSuspend()接口实现分析
深度优先搜索简要讲解(附带基础题)
postgresql 用户不能自己创建表格配置
Objective C attribute keyword
【罗技】m720
Illustrated network: what is the hot backup router protocol HSRP?
Penetration practice - sqlserver empowerment
Objective-C member variable permissions
XSS prevention
Management and thesis of job management system based on SSM
MySQL maxscale realizes read-write separation
idea修改主体颜色
The difference between bagging and boosting in machine learning