Created attachment 377 [details] 具体执行步骤 Description of problem: 执行modprobe --remove-dependencies卸载模块依赖不生效或把其他依赖模块安装上 具体步骤查看附件 Version-Release number of selected component (if applicable): # cat /etc/os-release NAME="Anolis OS" VERSION="23" ID="anolis" VERSION_ID="23" PLATFORM_ID="platform:an23" PRETTY_NAME="Anolis OS 23" ANSI_COLOR="0;31" HOME_URL="https://openanolis.cn/" BUG_REPORT_URL="https://bugzilla.openanolis.cn/" # modprobe --version kmod version 29 +ZSTD +XZ +ZLIB +LIBCRYPTO -EXPERIMENTAL How reproducible: Steps to Reproduce: 1.modprobe vfat,安装vfat模块 2.modprobe --remove-dependencies vfat,卸载vfat模块及依赖 3.卸载vfat模块及fat模块 4.modprobe --remove-dependencies vfat,卸载vfat模块及依赖 Actual results: 步骤2:卸载vfat模块及依赖失败(具体查看附件) 步骤4:未执行卸载,反而将vfat模块及fat模块安装上了(具体查看附件) Expected results: 步骤2:卸载vfat模块及依赖成功 步骤4:卸载vfat模块及依赖成功 Additional info:
查看modprobe的man手册: -r, --remove This option causes modprobe to remove rather than insert a module. If the modules it depends on are also unused, modprobe will try to remove them too. Unlike insertion, more than one module can be specified on the command line (it does not make sense to specify module parameters when removing modules). modprobe -r会卸载内核模块,同时如果该内核模块依赖的模块没有被引用,modprobe也会同步删除。 从lsmod信息查看,vfat依赖fat,加载时自动加载fat。 # lsmod | grep fat vfat 20480 0 fat 86016 1 vfat 卸载后fat也会被自动卸载: # modprobe -r vfat # lsmod | grep fat # echo $? 1 modprobe -r可以同时删除依赖,不必使用--remove-dependencies
从代码逻辑上看,加上--remove-dependencies是添加标记位,需要去获取模块的依赖项,单纯使用modprobe --remove-dependencies xxx并不会真正触发rmmod xxx操作。 这个行为在Anolis OS 8上也是同样的表现。 另外kmod已升级到30版本,--remove-dependencies选项已被Deprecated. # modprobe --version kmod version 30 # modprobe --help Usage: modprobe [options] [-i] [-b] modulename modprobe [options] -a [-i] [-b] modulename [modulename...] modprobe [options] -r [-i] modulename modprobe [options] -r -a [-i] modulename [modulename...] modprobe [options] -c modprobe [options] --dump-modversions filename Management Options: -a, --all Consider every non-argument to be a module name to be inserted or removed (-r) -r, --remove Remove modules instead of inserting --remove-dependencies Deprecated: use --remove-holders --remove-holders Also remove module holders (use together with -r) -w, --wait <MSEC> When removing a module, wait up to MSEC for module's refcount to become 0 so it can be removed (use together with -r) --first-time Fail if module already inserted or removed -i, --ignore-install Ignore install commands -i, --ignore-remove Ignore remove commands -b, --use-blacklist Apply blacklist to resolved alias. -f, --force Force module insertion or removal. implies --force-modversions and --force-vermagic --force-modversion Ignore module's version --force-vermagic Ignore module's version magic