美文网首页
修改FUSE Kernel模块

修改FUSE Kernel模块

作者: IvanGuan | 来源:发表于2019-08-08 16:09 被阅读0次

    fuse kernel patch

    备份旧的fuse kernel 模块

    mkdir /yunfei_kernel_bak
    cp -rp /usr/lib/modules/3.10.0-514.26.2.el7.x86_64/kernel/fs/fuse /yunfei_kernel_bak/
    
    [root@An2Cc117 fuse]# ls /yunfei_kernel_bak/fuse/
     cuse.ko  fuse.ko
    

    下载新的kernel源码,并安装

    kernel-3.10.0-514.26.2.el7.src.rpm
    
    url: http://ftp.iij.ad.jp/pub/linux/centos-vault/centos/7.3.1611/updates/Source/SPackages/
    
    rpm -ivh kernel-3.10.0-514.26.2.el7.src.rpm
    
    执行完毕之后会生成这个目录 /root/rpmbuild/ 在这里有我们期望的 linux-3.10.0-514.26.2.el7.tar.xz 
    

    下载kernel devel 源码包并安装

    url: [](http://ftp.iij.ad.jp/pub/linux/centos-vault/centos/7.3.1611/updates/x86_64/Packages/)
    
    [root@An2Cc117 kernels]# rpm -ivh /yunfei/kernel-devel-3.10.0-514.26.2.el7.x86_64.rpm
    准备中...                          ################################# [100%]
    正在升级/安装...
        1:kernel-devel-3.10.0-514.26.2.el7 ################################# [100%]
    

    配置编译环境

    yum groupinstall  "Development Tools" 
    yum install elfutils-libelf-devel -y
    

    开始修改并且编译新的fuse.ko

    mkdir /usr/src/kernels/newfuse
    
    cd /root/rpmbuild/SOURCES
    tar -Jxf linux-3.10.0-514.26.2.el7.tar.xz -C /usr/src/kernels/newfuse
    
    按照后面的patch修改fs/fuse/inode.c  (patch [Fuse: Add mount option to cache presence of security related xattr - Patchwork](https://patchwork.kernel.org/patch/9306393/))
    
    cd /usr/src/kernels/newfuse/linux-3.10.0-514.26.2.el7/
    cp /boot/config-3.10.0-514.26.2.el7.x86_64 .config
    cp /usr/src/kernels/3.10.0-514.26.2.el7.x86_64/Module.symvers /usr/src/kernels/newfuse/linux-3.10.0-514.26.2.el7/
    
    [root@An2Cc117 linux-3.10.0-514.26.2.el7]# make oldconfig
      HOSTCC  scripts/basic/fixdep
      HOSTCC  scripts/kconfig/conf.o
      SHIPPED scripts/kconfig/zconf.tab.c
      SHIPPED scripts/kconfig/zconf.lex.c
      SHIPPED scripts/kconfig/zconf.hash.c
      HOSTCC  scripts/kconfig/zconf.tab.o
      HOSTLD  scripts/kconfig/conf
    scripts/kconfig/conf --oldconfig Kconfig
    #
    # configuration written to .config
    #
    
    [root@An2Cc117 linux-3.10.0-514.26.2.el7]# make prepare
    scripts/kconfig/conf --silentoldconfig Kconfig
    Makefile:901: "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev or elfutils-libelf-devel"
      SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
      SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
      SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
      SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
      SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h
      SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h
      SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_64.h
      HOSTCC  scripts/basic/bin2c
      HOSTCC  arch/x86/tools/relocs_32.o
      HOSTCC  arch/x86/tools/relocs_64.o
      HOSTCC  arch/x86/tools/relocs_common.o
      HOSTLD  arch/x86/tools/relocs
      WRAP    arch/x86/include/generated/asm/clkdev.h
      WRAP    arch/x86/include/generated/asm/mm-arch-hooks.h
      CHK     include/generated/uapi/linux/version.h
      UPD     include/generated/uapi/linux/version.h
      CHK     include/generated/utsrelease.h
      UPD     include/generated/utsrelease.h
      CC      arch/x86/purgatory/purgatory.o
      AS      arch/x86/purgatory/stack.o
      AS      arch/x86/purgatory/setup-x86_64.o
      CC      arch/x86/purgatory/sha256.o
      AS      arch/x86/purgatory/entry64.o
      CC      arch/x86/purgatory/string.o
      LD      arch/x86/purgatory/purgatory.ro
      BIN2C   arch/x86/purgatory/kexec-purgatory.c
      CC      kernel/bounds.s
      GEN     include/generated/bounds.h
      CC      arch/x86/kernel/asm-offsets.s
      GEN     include/generated/asm-offsets.h
      CALL    scripts/checksyscalls.sh
    
    [root@An2Cc117 linux-3.10.0-514.26.2.el7]# make scripts
    Makefile:901: "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev or elfutils-libelf-devel"
      HOSTCC  scripts/genksyms/genksyms.o
      SHIPPED scripts/genksyms/lex.lex.c
      SHIPPED scripts/genksyms/keywords.hash.c
      SHIPPED scripts/genksyms/parse.tab.h
      HOSTCC  scripts/genksyms/lex.lex.o
      SHIPPED scripts/genksyms/parse.tab.c
      HOSTCC  scripts/genksyms/parse.tab.o
      HOSTLD  scripts/genksyms/genksyms
      CC      scripts/mod/empty.o
      HOSTCC  scripts/mod/mk_elfconfig
      MKELF   scripts/mod/elfconfig.h
      CC      scripts/mod/devicetable-offsets.s
      GEN     scripts/mod/devicetable-offsets.h
      HOSTCC  scripts/mod/file2alias.o
      HOSTCC  scripts/mod/modpost.o
      HOSTCC  scripts/mod/sumversion.o
      HOSTLD  scripts/mod/modpost
      HOSTCC  scripts/selinux/genheaders/genheaders
      HOSTCC  scripts/selinux/mdp/mdp
      HOSTCC  scripts/kallsyms
      HOSTCC  scripts/pnmtologo
      HOSTCC  scripts/conmakehash
      HOSTCC  scripts/recordmcount
      HOSTCC  scripts/sortextable
      HOSTCC  scripts/asn1_compiler
    
    [root@An2Cc117 linux-3.10.0-514.26.2.el7]# make CONFIG_FUSE_FS=m M=fs/fuse
      CC [M]  fs/fuse/inode.o
      LD [M]  fs/fuse/fuse.o
      Building modules, stage 2.
      MODPOST 2 modules
      CC      fs/fuse/fuse.mod.o
      LD [M]  fs/fuse/fuse.ko
    

    开始替换

    1.卸载掉所有的fuse mount点,并且 umount /sys/fs/fuse/connections/
    2.copy 新的fuse module到 old module
      [root@An2Cc117 linux-3.10.0-514.26.2.el7]# cp fs/fuse/fuse.ko /usr/lib/modules/3.10.0-514.26.2.el7.x86_64/kernel/fs/fuse/
      cp:是否覆盖"/usr/lib/modules/3.10.0-514.26.2.el7.x86_64/kernel/fs/fuse/fuse.ko"? y
    3. 卸载old fuse 模块
       rmmod fuse
       加载新的fuse 模块
       insmod /usr/lib/modules/3.10.0-514.26.2.el7.x86_64/kernel/fs/fuse/fuse.ko
    

    开始fuse挂载,只要挂在就会打印出来我添加的日志,证明fuse 内核模块编译成功

    fuse_start.png

    相关文章

      网友评论

          本文标题:修改FUSE Kernel模块

          本文链接:https://www.haomeiwen.com/subject/wkwxjctx.html