当前位置:首页>Linux>Linux文件系统专题

Linux文件系统专题

  • 2026-03-25 02:51:59
Linux文件系统专题

概述

Linux文件系统由VFS(Virtual File System)抽象层统一管理,屏蔽不同文件系统的实现差异。本专题深入剖析VFS架构、核心数据结构、ext4日志机制、以及如何实现自定义文件系统。


一、VFS架构总览

1.1 层次结构

用户空间:open/read/write/close syscalls
           ↓
VFS层:    super_block / inode / dentry / file
           ↓
文件系统:  ext4 / btrfs / xfs / tmpfs / procfs ...
           ↓
页缓存:    page cache(address_space)
           ↓
块设备层:  bio / blk-mq
           ↓
驱动层:    SCSI / NVMe / virtio-blk

1.2 核心数据结构关系

super_block  ←→  inode  ←→  dentry  ←→  file
(文件系统)     (文件元数据) (目录项/名字)  (打开的文件)

一个super_block对应一个挂载的文件系统
一个inode对应一个文件(可被多个dentry引用,即硬链接)
一个dentry对应一个路径分量(目录项缓存)
一个file对应一个打开的文件描述符(包含位置信息)
# 查看VFS信息
cat /proc/mounts          # 已挂载的文件系统
cat /proc/filesystems     # 注册的文件系统类型
cat /proc/sys/fs/inode-nr # inode使用统计
cat /proc/sys/fs/file-nr  # 文件句柄统计
cat /proc/sys/fs/dentry-state # dentry缓存统计

# 查看文件系统挂载统计
findmnt --tree

二、核心数据结构深度分析

2.1 super_block

// superblock_demo.c - 遍历已挂载的文件系统
#include<linux/module.h>
#include<linux/fs.h>
#include<linux/mount.h>
#include<linux/nsproxy.h>
#include<linux/mnt_namespace.h>

MODULE_LICENSE("GPL");

staticvoiddump_super_block(struct super_block *sb)
{
    pr_info("=== Superblock: %s ===\n", sb->s_type->name);
    pr_info("  Device:       %pg\n", sb->s_bdev ? sb->s_bdev : NULL);
    pr_info("  Block size:   %lu bytes\n", sb->s_blocksize);
    pr_info("  Max filesize: %lld bytes\n", sb->s_maxbytes);
    pr_info("  Inode count:  (see df -i)\n");
    pr_info("  Magic:        0x%lx\n", sb->s_magic);
    pr_info("  Flags:        0x%lx\n", sb->s_flags);
    pr_info("  Readonly:     %d\n", sb_rdonly(sb));

/* 文件系统操作表 */
if (sb->s_op) {
        pr_info("  Ops: statfs=%p alloc_inode=%p\n",
                sb->s_op->statfs,
                sb->s_op->alloc_inode);
    }
}

staticint __init sb_demo_init(void)
{
structsuper_block *sb;

/* 遍历所有挂载的超级块 */
    spin_lock(&sb_lock);
    list_for_each_entry(sb, &super_blocks, s_list) {
if (atomic_read(&sb->s_active) > 0)
            dump_super_block(sb);
    }
    spin_unlock(&sb_lock);

return0;
}

staticvoid __exit sb_demo_exit(void) {}

module_init(sb_demo_init);
module_exit(sb_demo_exit);

2.2 inode深度分析

// inode_demo.c - inode结构分析
#include<linux/module.h>
#include<linux/fs.h>
#include<linux/namei.h>
#include<linux/stat.h>

MODULE_LICENSE("GPL");

staticvoiddump_inode(struct inode *inode, constchar *path)
{
    pr_info("=== Inode: %s ===\n", path);
    pr_info("  ino:         %lu\n", inode->i_ino);
    pr_info("  mode:        %o\n", inode->i_mode);
    pr_info("  uid:         %u\n", i_uid_read(inode));
    pr_info("  gid:         %u\n", i_gid_read(inode));
    pr_info("  size:        %lld bytes\n", i_size_read(inode));
    pr_info("  blocks:      %llu\n", (u64)inode->i_blocks);
    pr_info("  nlink:       %u\n", inode->i_nlink);
    pr_info("  blksize:     %u\n", inode->i_blkbits);

/* 时间戳 */
    pr_info("  atime:       %lld\n", inode->i_atime.tv_sec);
    pr_info("  mtime:       %lld\n", inode->i_mtime.tv_sec);
    pr_info("  ctime:       %lld\n", inode->i_ctime.tv_sec);

/* 引用计数 */
    pr_info("  i_count:     %u\n"atomic_read(&inode->i_count));

/* 类型判断 */
    pr_info("  type:        %s\n",
            S_ISREG(inode->i_mode)  ? "regular file" :
            S_ISDIR(inode->i_mode)  ? "directory" :
            S_ISLNK(inode->i_mode)  ? "symlink" :
            S_ISBLK(inode->i_mode)  ? "block device" :
            S_ISCHR(inode->i_mode)  ? "char device" :
            S_ISFIFO(inode->i_mode) ? "fifo" :
            S_ISSOCK(inode->i_mode) ? "socket" : "unknown");

/* 操作表 */
if (inode->i_op)
        pr_info("  i_op->lookup:  %p\n", inode->i_op->lookup);
if (inode->i_fop)
        pr_info("  i_fop->read:   %p\n", inode->i_fop->read);
}

staticint __init inode_demo_init(void)
{
structpathpath;
int ret;

/* 查找/etc/passwd的inode */
    ret = kern_path("/etc/passwd", LOOKUP_FOLLOW, &path);
if (ret == 0) {
        dump_inode(d_inode(path.dentry), "/etc/passwd");
        path_put(&path);
    }

/* 查找/proc的inode */
    ret = kern_path("/proc", LOOKUP_FOLLOW, &path);
if (ret == 0) {
        dump_inode(d_inode(path.dentry), "/proc");
        path_put(&path);
    }

return0;
}

staticvoid __exit inode_demo_exit(void) {}

module_init(inode_demo_init);
module_exit(inode_demo_exit);

2.3 dentry缓存

// dentry_demo.c - dentry缓存与路径查找
#include<linux/module.h>
#include<linux/fs.h>
#include<linux/dcache.h>
#include<linux/namei.h>
#include<linux/path.h>

MODULE_LICENSE("GPL");

staticvoiddump_dentry(struct dentry *dentry, int depth)
{
char indent[64];
int i;

if (depth > 5return;  /* 避免递归太深 */

memset(indent, ' ', depth * 2);
    indent[depth * 2] = '\0';

    pr_info("%s%s (ino=%lu, flags=0x%x, count=%d)\n",
            indent,
            dentry->d_name.name,
            dentry->d_inode ? dentry->d_inode->i_ino : 0,
            dentry->d_flags,
            (int)d_count(dentry));
}

/* 通过路径查找dentry */
staticvoidpath_lookup_demo(constchar *pathname)
{
structpathpath;
char buf[256];
char *full_path;

if (kern_path(pathname, LOOKUP_FOLLOW, &path) != 0) {
        pr_err("Path not found: %s\n", pathname);
return;
    }

/* 获取完整路径 */
    full_path = d_path(&path, buf, sizeof(buf));
if (!IS_ERR(full_path)) {
        pr_info("Resolved path: %s -> %s\n", pathname, full_path);
    }

    dump_dentry(path.dentry, 0);

/* 查看父目录dentry */
if (path.dentry->d_parent != path.dentry) {
        pr_info("Parent: %s\n",
                path.dentry->d_parent->d_name.name);
    }

    path_put(&path);
}

staticint __init dentry_demo_init(void)
{
    pr_info("=== Dentry Demo ===\n");
    path_lookup_demo("/etc/passwd");
    path_lookup_demo("/proc/self");
    path_lookup_demo("/tmp");
return0;
}

staticvoid __exit dentry_demo_exit(void) {}

module_init(dentry_demo_init);
module_exit(dentry_demo_exit);

三、文件操作流程追踪

3.1 open()系统调用链

/*
 * open("/etc/passwd", O_RDONLY) 内核调用链:
 *
 * sys_openat()
 *   → do_sys_openat2()
 *     → do_filp_open()
 *       → path_openat()
 *         → link_path_walk()    ← 路径解析(逐分量查找dentry)
 *           → walk_component()
 *             → lookup_fast()   ← dentry缓存查找
 *             → lookup_slow()   ← 调用inode->i_op->lookup()
 *         → do_open()
 *           → vfs_open()
 *             → do_dentry_open()
 *               → inode->i_fop->open()  ← 调用具体文件系统的open
 */

# 用strace观察open的完整过程
strace -e trace=openat,read,close cat /etc/passwd 2>&1 | head -20

# 用ftrace追踪VFS调用
cd /sys/kernel/debug/tracing
echo 0 > tracing_on
echofunction > current_tracer
echo'vfs_*' > set_ftrace_filter
echo 1 > tracing_on
cat /etc/passwd > /dev/null
echo 0 > tracing_on
cat trace | head -30
echo nop > current_tracer
echo > set_ftrace_filter

3.2 read()调用链与页缓存

/*
 * read() 调用链(文件数据可能在页缓存中):
 *
 * sys_read()
 *   → vfs_read()
 *     → new_sync_read()
 *       → file->f_op->read_iter()    ← 具体文件系统实现
 *         → generic_file_read_iter() ← 通用实现(走页缓存)
 *           → filemap_read()
 *             → find_get_pages_contig()  ← 在页缓存中查找
 *             → page_cache_sync_readahead() ← 缓存未命中,触发读取
 *               → ext4_readpages()    ← 从磁盘读取
 */

# 查看页缓存统计
cat /proc/meminfo | grep -E "Cached|Buffers|Dirty|Writeback"

# 查看特定文件的页缓存占用
# 需要pcstat工具:go install github.com/tobert/pcstat@latest
# pcstat /path/to/large/file

# 清空页缓存(测试用)
echo 1 | sudo tee /proc/sys/vm/drop_caches

# 使用vmtouch查看/控制页缓存
# sudo apt install vmtouch
vmtouch /etc/passwd          # 查看缓存状态
vmtouch -t /etc/passwd       # 预热到缓存
vmtouch -e /etc/passwd       # 从缓存驱逐

四、ext4文件系统深度解析

4.1 ext4磁盘布局

Block Group 0:
+-----------+--------+-----------+-------+--------+-------+
| Superblock| Group  | Block     | Inode | Inode  | Data  |
|           |Descr.  | Bitmap    | Bitmap| Table  | Blocks|
+-----------+--------+-----------+-------+--------+-------+

关键参数(典型4KB块大小):
- Block size:       4096 bytes
- Inodes per group: 8192
- Blocks per group: 32768(128MB per group)
- max file size:    ~16TB
- max fs size:      1EB
# 查看ext4文件系统详细信息
sudo tune2fs -l /dev/sda1

# 查看块组信息
sudo dumpe2fs /dev/sda1 | head -80

# 查看inode详情
sudo debugfs /dev/sda1
(debugfs) stat /etc/passwd     # 查看inode
(debugfs) blocks /etc/passwd   # 查看数据块
(debugfs) dump /etc/passwd /tmp/passwd_copy  # 导出文件
(debugfs) quit

# 查看extent树(ext4使用extent代替间接块)
sudo debugfs -R "extents /etc/passwd" /dev/sda1

4.2 ext4 Extent树

/*
 * ext4 Extent(区段)结构:
 * 将连续的逻辑块映射到连续的物理块
 * 比传统间接块(indirect block)更高效
 *
 * struct ext4_extent {
 *     __le32 ee_block;   // 起始逻辑块号
 *     __le16 ee_len;     // 长度(块数)
 *     __le16 ee_start_hi; // 起始物理块(高16位)
 *     __le32 ee_start_lo; // 起始物理块(低32位)
 * };
 */

# 查看文件的extent分配情况
sudo filefrag -v /path/to/file

# 对碎片化文件进行碎片整理
sudo e4defrag /path/to/file

# 查看文件系统碎片程度
sudo e2freefrag /dev/sda1

# 预分配磁盘空间(减少碎片)
fallocate -l 1G /tmp/bigfile

# 查看文件预分配情况
stat /tmp/bigfile

4.3 日志(Journal)机制

# 查看日志模式
sudo tune2fs -l /dev/sda1 | grep "Journal features"

# ext4日志模式:
# journal:  数据和元数据都写日志(最安全,最慢)
# ordered:  只写元数据日志,数据先写磁盘(默认,平衡)
# writeback: 只写元数据日志,数据可能乱序(最快,最不安全)

# 修改日志模式(重新挂载)
sudo mount -o remount,data=writeback /dev/sda1 /mount/point

# 查看日志大小
sudo tune2fs -l /dev/sda1 | grep "Journal size"

# 挂载时指定日志模式(/etc/fstab)
# /dev/sda1 / ext4 defaults,data=ordered 0 1

五、实现自定义文件系统

5.1 最小内存文件系统(完整版)

// myfs.c - 完整的最小内存文件系统实现
#include<linux/module.h>
#include<linux/init.h>
#include<linux/fs.h>
#include<linux/pagemap.h>
#include<linux/slab.h>
#include<linux/stat.h>
#include<linux/string.h>
#include<linux/time.h>
#include<linux/uio.h>

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Minimal memory filesystem");

#define MYFS_MAGIC    0x4D594653  /* "MYFS" */
#define MYFS_DEFAULT_MODE  0755

/* ===== 文件操作 ===== */

staticintmyfs_file_open(struct inode *inode, struct file *file)
{
    pr_info("myfs: open %s\n", file->f_path.dentry->d_name.name);
return generic_file_open(inode, file);
}

/* 使用页缓存的通用读写操作 */
staticconststructfile_operationsmyfs_file_fops = {
    .open           = myfs_file_open,
    .read_iter      = generic_file_read_iter,
    .write_iter     = generic_file_write_iter,
    .mmap           = generic_file_mmap,
    .fsync          = noop_fsync,
    .llseek         = generic_file_llseek,
};

/* ===== 地址空间操作(页缓存) ===== */
staticconststructaddress_space_operationsmyfs_aops = {
    .read_folio     = simple_read_folio,
    .write_begin    = simple_write_begin,
    .write_end      = simple_write_end,
    .dirty_folio    = noop_dirty_folio,
};

/* ===== inode操作 ===== */

/* 创建文件 */
staticintmyfs_create(struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode, bool excl)

{
structinode *inode;

    inode = new_inode(dir->i_sb);
if (!inode)
return -ENOMEM;

    inode->i_ino     = get_next_ino();
    inode->i_mode    = mode | S_IFREG;
    inode->i_uid     = current_fsuid();
    inode->i_gid     = current_fsgid();
    inode->i_blocks  = 0;
    inode->i_atime   =
    inode->i_mtime   =
    inode->i_ctime   = current_time(inode);
    inode->i_op      = &simple_symlink_inode_operations;
    inode->i_fop     = &myfs_file_fops;
    inode->i_mapping->a_ops = &myfs_aops;

    d_instantiate(dentry, inode);
    dget(dentry);
    pr_info("myfs: created file %s\n", dentry->d_name.name);
return0;
}

/* 创建目录 */
staticintmyfs_mkdir(struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)

{
structinode *inode;

    inode = new_inode(dir->i_sb);
if (!inode)
return -ENOMEM;

    inode->i_ino   = get_next_ino();
    inode->i_mode  = mode | S_IFDIR;
    inode->i_uid   = current_fsuid();
    inode->i_gid   = current_fsgid();
    inode->i_atime =
    inode->i_mtime =
    inode->i_ctime = current_time(inode);
    inode->i_op    = &simple_dir_inode_operations;
    inode->i_fop   = &simple_dir_operations;
    set_nlink(inode, 2);

    inc_nlink(dir);
    d_instantiate(dentry, inode);
    dget(dentry);
    pr_info("myfs: created dir %s\n", dentry->d_name.name);
return0;
}

staticconststructinode_operationsmyfs_dir_inode_ops = {
    .create     = myfs_create,
    .lookup     = simple_lookup,
    .link       = simple_link,
    .unlink     = simple_unlink,
    .mkdir      = myfs_mkdir,
    .rmdir      = simple_rmdir,
    .rename     = simple_rename,
};

/* ===== 超级块操作 ===== */

staticconststructsuper_operationsmyfs_super_ops = {
    .statfs     = simple_statfs,
    .drop_inode = generic_delete_inode,
};

/* 填充超级块 */
staticintmyfs_fill_super(struct super_block *sb, void *data, int silent)
{
structinode *root_inode;
structdentry *root_dentry;

/* 设置超级块参数 */
    sb->s_maxbytes      = MAX_LFS_FILESIZE;
    sb->s_blocksize     = PAGE_SIZE;
    sb->s_blocksize_bits = PAGE_SHIFT;
    sb->s_magic         = MYFS_MAGIC;
    sb->s_op            = &myfs_super_ops;
    sb->s_time_gran     = 1;

/* 创建根inode */
    root_inode = new_inode(sb);
if (!root_inode)
return -ENOMEM;

    root_inode->i_ino   = 1;
    root_inode->i_mode  = S_IFDIR | MYFS_DEFAULT_MODE;
    root_inode->i_uid   = GLOBAL_ROOT_UID;
    root_inode->i_gid   = GLOBAL_ROOT_GID;
    root_inode->i_atime =
    root_inode->i_mtime =
    root_inode->i_ctime = current_time(root_inode);
    root_inode->i_op    = &myfs_dir_inode_ops;
    root_inode->i_fop   = &simple_dir_operations;
    set_nlink(root_inode, 2);

/* 创建根dentry */
    root_dentry = d_make_root(root_inode);
if (!root_dentry)
return -ENOMEM;

    sb->s_root = root_dentry;
    pr_info("myfs: filesystem mounted\n");
return0;
}

/* ===== 文件系统类型 ===== */

staticstruct dentry *myfs_mount(struct file_system_type *fs_type,
int flags,
constchar *dev_name,
void *data)

{
return mount_nodev(fs_type, flags, data, myfs_fill_super);
}

staticvoidmyfs_kill_sb(struct super_block *sb)
{
    kill_litter_super(sb);
    pr_info("myfs: filesystem unmounted\n");
}

staticstructfile_system_typemyfs_type = {
    .owner      = THIS_MODULE,
    .name       = "myfs",
    .mount      = myfs_mount,
    .kill_sb    = myfs_kill_sb,
};

staticint __init myfs_init(void)
{
int ret = register_filesystem(&myfs_type);
if (ret == 0)
        pr_info("myfs: registered. Usage: mount -t myfs none /mnt/myfs\n");
return ret;
}

staticvoid __exit myfs_exit(void)
{
    unregister_filesystem(&myfs_type);
    pr_info("myfs: unregistered\n");
}

module_init(myfs_init);
module_exit(myfs_exit);
# 编译并使用自定义文件系统
make -C /lib/modules/$(uname -r)/build M=$PWD modules
sudo insmod myfs.ko

# 挂载
sudo mkdir /mnt/myfs
sudo mount -t myfs none /mnt/myfs

# 测试
echo"Hello myfs" | sudo tee /mnt/myfs/test.txt
cat /mnt/myfs/test.txt
ls -la /mnt/myfs/
sudo mkdir /mnt/myfs/subdir
df -h /mnt/myfs

# 卸载
sudo umount /mnt/myfs
sudo rmmod myfs

六、proc文件系统实现

6.1 使用seq_file创建proc接口

// proc_demo.c - proc文件系统完整示例
#include<linux/module.h>
#include<linux/proc_fs.h>
#include<linux/seq_file.h>
#include<linux/slab.h>
#include<linux/uaccess.h>

MODULE_LICENSE("GPL");

/* ===== 1. 简单只读proc文件 ===== */

staticintsimple_show(struct seq_file *m, void *v)
{
    seq_printf(m, "Hello from proc!\n");
    seq_printf(m, "jiffies: %lu\n", jiffies);
    seq_printf(m, "HZ: %d\n", HZ);
return0;
}

staticintsimple_open(struct inode *inode, struct file *file)
{
return single_open(file, simple_show, NULL);
}

staticconststructproc_opssimple_fops = {
    .proc_open    = simple_open,
    .proc_read    = seq_read,
    .proc_lseek   = seq_lseek,
    .proc_release = single_release,
};

/* ===== 2. 可读写proc文件 ===== */

staticchar rw_buffer[256] = "default value\n";
staticsize_t rw_len = 15;

staticintrw_show(struct seq_file *m, void *v)
{
    seq_write(m, rw_buffer, rw_len);
return0;
}

staticintrw_open(struct inode *inode, struct file *file)
{
return single_open(file, rw_show, NULL);
}

staticssize_trw_write(struct file *file,
constchar __user *ubuf,
size_t count, loff_t *ppos)

{
if (count >= sizeof(rw_buffer))
        count = sizeof(rw_buffer) - 1;

if (copy_from_user(rw_buffer, ubuf, count))
return -EFAULT;

    rw_buffer[count] = '\0';
    rw_len = count;
    pr_info("proc rw: wrote %zu bytes: %s", count, rw_buffer);
return count;
}

staticconststructproc_opsrw_fops = {
    .proc_open    = rw_open,
    .proc_read    = seq_read,
    .proc_write   = rw_write,
    .proc_lseek   = seq_lseek,
    .proc_release = single_release,
};

/* ===== 3. 迭代器模式(适合多行输出)===== */

structmy_item {
int id;
char name[32];
structlist_headlist;
};

staticLIST_HEAD(my_list);

staticvoid *my_seq_start(struct seq_file *m, loff_t *pos)
{
return seq_list_start(&my_list, *pos);
}

staticvoid *my_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
return seq_list_next(v, &my_list, pos);
}

staticvoidmy_seq_stop(struct seq_file *m, void *v) {}

staticintmy_seq_show(struct seq_file *m, void *v)
{
structmy_item *item = list_entry(v, struct my_item, list);
    seq_printf(m, "%3d: %s\n", item->id, item->name);
return0;
}

staticconststructseq_operationsmy_seq_ops = {
    .start = my_seq_start,
    .next  = my_seq_next,
    .stop  = my_seq_stop,
    .show  = my_seq_show,
};

staticintlist_open(struct inode *inode, struct file *file)
{
return seq_open(file, &my_seq_ops);
}

staticconststructproc_opslist_fops = {
    .proc_open    = list_open,
    .proc_read    = seq_read,
    .proc_lseek   = seq_lseek,
    .proc_release = seq_release,
};

/* ===== 初始化 ===== */

staticstructproc_dir_entry *proc_dir;
staticstructproc_dir_entry *proc_simple, *proc_rw, *proc_list;

staticint __init proc_demo_init(void)
{
int i;
structmy_item *item;

/* 创建proc目录 */
    proc_dir = proc_mkdir("demo"NULL);
if (!proc_dir)
return -ENOMEM;

    proc_simple = proc_create("info"0444, proc_dir, &simple_fops);
    proc_rw     = proc_create("value"0644, proc_dir, &rw_fops);
    proc_list   = proc_create("list"0444, proc_dir, &list_fops);

/* 填充链表 */
for (i = 0; i < 5; i++) {
        item = kmalloc(sizeof(*item), GFP_KERNEL);
if (!item) break;
        item->id = i;
snprintf(item->name, sizeof(item->name), "item_%d", i);
        list_add_tail(&item->list, &my_list);
    }

    pr_info("proc_demo: created /proc/demo/{info,value,list}\n");
    pr_info("  cat /proc/demo/info\n");
    pr_info("  echo 'hello' > /proc/demo/value\n");
    pr_info("  cat /proc/demo/list\n");
return0;
}

staticvoid __exit proc_demo_exit(void)
{
structmy_item *item, *tmp;

    proc_remove(proc_dir);

    list_for_each_entry_safe(item, tmp, &my_list, list) {
        list_del(&item->list);
        kfree(item);
    }
}

module_init(proc_demo_init);
module_exit(proc_demo_exit);

七、FUSE(用户空间文件系统)

7.1 FUSE架构

用户程序 read("/mnt/fuse/file")
         ↓
VFS → FUSE内核模块(/dev/fuse)
         ↓ (通过/dev/fuse传递请求)
用户态FUSE守护进程(libfuse)
         ↓ (实现文件操作逻辑)
返回结果给内核
// hello_fuse.c - 最小FUSE文件系统(使用libfuse3)
// 编译:gcc hello_fuse.c -o hello_fuse $(pkg-config fuse3 --cflags --libs)
// 运行:./hello_fuse /mnt/fuse -f
// 测试:cat /mnt/fuse/hello
// 卸载:fusermount3 -u /mnt/fuse

#define FUSE_USE_VERSION 31
#include<fuse3/fuse.h>
#include<stdio.h>
#include<string.h>
#include<errno.h>
#include<fcntl.h>
#include<stddef.h>
#include<assert.h>

staticconstchar *hello_path = "/hello";
staticconstchar *hello_content = "Hello from FUSE filesystem!\n";

staticinthello_getattr(constchar *path, struct stat *stbuf,
struct fuse_file_info *fi)

{
memset(stbuf, 0sizeof(*stbuf));

if (strcmp(path, "/") == 0) {
        stbuf->st_mode  = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
return0;
    }

if (strcmp(path, hello_path) == 0) {
        stbuf->st_mode  = S_IFREG | 0444;
        stbuf->st_nlink = 1;
        stbuf->st_size  = strlen(hello_content);
return0;
    }

return -ENOENT;
}

staticinthello_readdir(constchar *path, void *buf,
fuse_fill_dir_t filler,
off_t offset,
struct fuse_file_info *fi,
enum fuse_readdir_flags flags)

{
if (strcmp(path, "/") != 0)
return -ENOENT;

    filler(buf, ".",     NULL00);
    filler(buf, "..",    NULL00);
    filler(buf, "hello"NULL00);
return0;
}

staticinthello_open(constchar *path, struct fuse_file_info *fi)
{
if (strcmp(path, hello_path) != 0)
return -ENOENT;

if ((fi->flags & O_ACCMODE) != O_RDONLY)
return -EACCES;

return0;
}

staticinthello_read(constchar *path, char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)

{
size_t len = strlen(hello_content);

if (strcmp(path, hello_path) != 0)
return -ENOENT;

if (offset >= (off_t)len)
return0;

if (offset + size > len)
        size = len - offset;

memcpy(buf, hello_content + offset, size);
return size;
}

staticconststructfuse_operationshello_oper = {
    .getattr  = hello_getattr,
    .readdir  = hello_readdir,
    .open     = hello_open,
    .read     = hello_read,
};

intmain(int argc, char *argv[])
{
return fuse_main(argc, argv, &hello_oper, NULL);
}

八、文件系统调试与分析

8.1 常用调试命令

# 查看挂载点的文件系统统计
df -h
df -i   # inode使用情况

# 查看文件的物理块分配
sudo filefrag -v /path/to/file

# 查看目录树磁盘使用
du -sh /var/log/*
du --max-depth=1 /var

# 检查文件系统错误(需先卸载)
sudo fsck.ext4 -n /dev/sda1  # -n: 只检查不修复

# 查看磁盘I/O统计
iostat -x 1 5

# 监控文件系统事件(需要inotify-tools)
sudo apt install inotify-tools
inotifywait -m -r /tmp  # 监控/tmp下所有事件

8.2 inotify内核模块

// inotify_demo.c - 使用inotify监控文件事件
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/inotify.h>
#include<unistd.h>
#include<fcntl.h>
#include<errno.h>

#define EVENT_SIZE  (sizeof(struct inotify_event))
#define BUF_LEN     (1024 * (EVENT_SIZE + 16))

intmain(int argc, char *argv[])
{
int ifd, wd;
char buf[BUF_LEN];
constchar *watchdir = argc > 1 ? argv[1] : "/tmp";

    ifd = inotify_init1(IN_NONBLOCK);
if (ifd < 0) {
        perror("inotify_init1");
return1;
    }

/* 监控指定目录 */
    wd = inotify_add_watch(ifd, watchdir,
                           IN_CREATE | IN_DELETE |
                           IN_MODIFY | IN_MOVED_FROM |
                           IN_MOVED_TO | IN_CLOSE_WRITE);
if (wd < 0) {
        perror("inotify_add_watch");
return1;
    }

printf("Watching: %s (press Ctrl+C to stop)\n", watchdir);

while (1) {
ssize_t len = read(ifd, buf, BUF_LEN);
if (len < 0) {
if (errno == EAGAIN) {
                usleep(100000);  /* 100ms */
continue;
            }
            perror("read");
break;
        }

char *ptr = buf;
while (ptr < buf + len) {
structinotify_event *event = (struct inotify_event *)ptr;

constchar *event_name = "";
if (event->mask & IN_CREATE)      event_name = "CREATE";
if (event->mask & IN_DELETE)      event_name = "DELETE";
if (event->mask & IN_MODIFY)      event_name = "MODIFY";
if (event->mask & IN_MOVED_FROM)  event_name = "MOVED_FROM";
if (event->mask & IN_MOVED_TO)    event_name = "MOVED_TO";
if (event->mask & IN_CLOSE_WRITE) event_name = "CLOSE_WRITE";
if (event->mask & IN_ISDIR)       printf("[DIR] ");

printf("%-12s %s/%s\n",
                   event_name,
                   watchdir,
                   event->len ? event->name : "");

            ptr += EVENT_SIZE + event->len;
        }
    }

    inotify_rm_watch(ifd, wd);
    close(ifd);
return0;
}

实践检查清单

VFS基础

  • [ ] 能描述 super_blockinodedentryfile四者的关系
  • [ ] 理解open()系统调用中路径解析的完整流程
  • [ ] 理解 dentry 缓存的作用和负向缓存(negative dentry)
  • [ ] 能用kern_path()在内核中查找文件路径

ext4

  • [ ] 理解 ext4 的 Block Group 结构
  • [ ] 理解 Extent 树相比传统间接块的优势
  • [ ] 理解 journal 三种模式(journal/ordered/writeback)的区别
  • [ ] 能用 debugfs 检查 ext4 文件系统的内部结构

自定义文件系统

  • [ ] 能实现最小内存文件系统并成功挂载
  • [ ] 理解 mount_nodevmount_bdev 的区别
  • [ ] 能用 seq_file + proc_fs 创建可读写的/proc接口
  • [ ] 能用 libfuse 实现用户空间文件系统

调试工具

  • [ ] 用 filefrag检查文件碎片化程度
  • [ ] 用 inotify实现文件变化监控程序
  • [ ] 用 ftrace 追踪 VFS 函数调用链
  • [ ] 用 strace分析文件操作的系统调用序列

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 11:26:24 HTTP/2.0 GET : https://f.mffb.com.cn/a/480811.html
  2. 运行时间 : 0.092736s [ 吞吐率:10.78req/s ] 内存消耗:4,980.02kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=dad20962ebaea93f54634db024d0c63c
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000504s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000693s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000299s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000263s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000512s ]
  6. SELECT * FROM `set` [ RunTime:0.000263s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000620s ]
  8. SELECT * FROM `article` WHERE `id` = 480811 LIMIT 1 [ RunTime:0.001590s ]
  9. UPDATE `article` SET `lasttime` = 1774581984 WHERE `id` = 480811 [ RunTime:0.001862s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000281s ]
  11. SELECT * FROM `article` WHERE `id` < 480811 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000467s ]
  12. SELECT * FROM `article` WHERE `id` > 480811 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000413s ]
  13. SELECT * FROM `article` WHERE `id` < 480811 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001341s ]
  14. SELECT * FROM `article` WHERE `id` < 480811 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001683s ]
  15. SELECT * FROM `article` WHERE `id` < 480811 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.005469s ]
0.094369s