diff --git a/internal/configs/config_initramfstools.go b/internal/configs/config_initramfstools.go index ece3076..bd63a5f 100644 --- a/internal/configs/config_initramfstools.go +++ b/internal/configs/config_initramfstools.go @@ -13,7 +13,7 @@ import ( ) // Special function to read the header of a file (reads the first N lines) -func readHeader(lines int, fileName string) string { +func initramfs_readHeader(lines int, fileName string) string { // Open the file f, err := os.Open(fileName) errorcheck.ErrorCheck(err, fmt.Sprintf("Error opening %s", fileName)) @@ -39,7 +39,7 @@ func readHeader(lines int, fileName string) string { // Reads the system file and copies over the content while inserting the vfio modules // Takes the config file as argument -func addModules(conffile string) { +func initramfs_addModules(conffile string) { // Make a regex to get the system path instead of the config path syspath_re := regexp.MustCompile(`^config`) diff --git a/internal/configs/configs.go b/internal/configs/configs.go index 8b771e7..e874a7a 100644 --- a/internal/configs/configs.go +++ b/internal/configs/configs.go @@ -110,10 +110,22 @@ func InitConfigs() { // If we now have a config that exists if _, err := os.Stat(conffile); !errors.Is(err, os.ErrNotExist) { - header := readHeader(4, sysfile) - fileio.AppendContent(header, conffile) - // TODO: Generalize this to a meta function - addModules(conffile) + switch conffile { + case config.path.ETCMODULES: + // Read the header + header := initramfs_readHeader(4, sysfile) + fileio.AppendContent(header, conffile) + + // Add the modules to the config file + initramfs_addModules(conffile) + case config.path.INITRAMFS: + // Read the header + header := initramfs_readHeader(11, sysfile) + fileio.AppendContent(header, conffile) + + // Add the modules to the config file + initramfs_addModules(conffile) + } } }