futureproofing function names for the different initramfs systems
This commit is contained in:
parent
efd8ae0f97
commit
f5116648e6
2 changed files with 18 additions and 6 deletions
|
@ -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`)
|
||||
|
||||
|
|
|
@ -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)
|
||||
switch conffile {
|
||||
case config.path.ETCMODULES:
|
||||
// Read the header
|
||||
header := initramfs_readHeader(4, sysfile)
|
||||
fileio.AppendContent(header, conffile)
|
||||
// TODO: Generalize this to a meta function
|
||||
addModules(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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue