Commit 4cbebce8 authored by jan.koester's avatar jan.koester
Browse files

test

parent a32f559e
Loading
Loading
Loading
Loading
+20 −2
Changes for commands/system/mkinitramfs.cpp: 20 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -444,6 +444,17 @@ namespace fresh { namespace cmd {
            return (bool)out;
        }

        static bool writeConsoleEntry(std::ofstream &out,const std::string &name,size_t &archiveOff){
            struct stat st;
            std::memset(&st,0,sizeof(st));
            st.st_mode=S_IFCHR|0600;
            st.st_nlink=1;
            st.st_rdev=makedev(5,1);
            if(!writeCpioEntry(out,name,&st,"",archiveOff)) return false;
            padTo4(out,archiveOff);
            return true;
        }

        static bool writeCpioFileContent(std::ofstream &out,const std::string &path,
                                          unsigned long filesize,size_t &archiveOff){
            std::ifstream in(path.c_str(),std::ios::binary);
@@ -505,12 +516,19 @@ namespace fresh { namespace cmd {
                names.push_back(n);
            }
            closedir(d);
            bool addConsole=archiveName=="./dev" &&
                std::find(names.begin(),names.end(),"console")==names.end();
            if(addConsole) names.push_back("console");
            std::sort(names.begin(),names.end()); // reproducible archive contents

            bool ok=true;
            for(const auto &n: names)
                if(!archiveRecursive(out,fsPath+"/"+n,archiveName+"/"+n,archiveOff))
            for(const auto &n: names){
                bool entryOk=(addConsole && n=="console")
                    ? writeConsoleEntry(out,archiveName+"/console",archiveOff)
                    : archiveRecursive(out,fsPath+"/"+n,archiveName+"/"+n,archiveOff);
                if(!entryOk)
                    ok=false;
            }
            return ok;
        }