Commit 00457c7f authored by jan.koester's avatar jan.koester
Browse files

depmod

parent 8aa6b07f
Loading
Loading
Loading
Loading
+25 −1
Changes for commands/modutils/depmod.cpp: 25 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -189,8 +189,32 @@ namespace fresh { namespace cmd {
            return base;
        }

        // Mirrors real depmod's argv shape as used by the kernel's own
        // scripts/depmod.sh: "-ae -F <System.map> [-b <basedir>] <release>".
        // The final positional argument is a kernel release string, not a
        // path -- depmod combines it with -b's basedir (default "") as
        // "<basedir>/lib/modules/<release>", same as real depmod. -F's
        // System.map argument is accepted and ignored (this depmod trusts
        // each .ko's own .modinfo "depends" field instead of resolving
        // symbols against System.map).
        int runCommand(int argc,const char **argv){
            std::string dir=(argc>1) ? argv[argc-1] : "/lib/modules";
            std::string basedir;
            std::string release;
            for(int i=1;i<argc;++i){
                std::string arg=argv[i];
                if(arg=="-b"){
                    if(i+1<argc) basedir=argv[++i];
                }else if(arg=="-F"){
                    if(i+1<argc) ++i;
                }else if(!arg.empty() && arg[0]=='-'){
                    // unary flag (-a, -e, -q, -v, -n, ...): no-op here
                }else{
                    release=arg;
                }
            }
            std::string dir=release.empty()
                ? (basedir.empty() ? "/lib/modules" : basedir)
                : basedir+"/lib/modules/"+release;

            std::vector<std::string> koFiles;
            findKoFiles(dir,koFiles);