Additional patch for the pull request

Thomas Neumann blacky+fai at fluffbunny.de
Wed Aug 6 14:35:32 CEST 2014


Hello

I have compiled a patch that can be applied on top of my recent pull request.

https://github.com/ThomasNeumann/setup-storage/commit/4075164711116a747809553bb4220b1e8fc711e4
-------------------------------------------------------------------------------
generate actual disk_var output in Fstab.pm and use generic file writer 
Change 1) generate 'ready-to-use' content for disk_var.sh instead of hash

Change 2) since the output for fstab, @disk_var and @crypttab is provided
          as an array it is possible to convert the 3 separate file writer
          routines into a common/generic function
-------------------------------------------------------------------------------

The main intention is to get rid of the repeated generation of the
disk_var.sh content for debug output (line 256) and for the actual
file (line 263).

256: $FAI::debug and print "$_=\${$_:-$FAI::disk_var{$_}}\n"
[...]
263: print DISK_VAR "$_=\${$_:-$FAI::disk_var{$_}}\n" foreach (keys %FAI::disk_var);

This is dangerous because if they are not kept in sync then the debug
output will show something else then the actual file content.
=> Solution: Generate the output only once. 

As an optimization the code has been moved to Fstab.pm. The content for
'fstab', 'crypttab' and 'disk_var.sh' is now provided as an array in all
three cases and the setup-storage script does not have to care about the
disk_var hash any more. (All logic related to the content of fstab and
disk_var is now contained in 'Fstab.pm'.)

Another optimization is to use a generic file writer 'writefile()' instead
of repeating roughly the same code 3 times.


The patch may looks a bit scary/invasive, but if you look at the result it
should be obvious what is going on -> 
https://github.com/ThomasNeumann/setup-storage/blob/refactor_Fstab.pm+1/bin/setup-storage
(lines 241-278) 

bye
thomas
-------------- next part --------------
An embedded message was scrubbed...
From: Thomas Neumann <blacky+fai at fluffbunny.de>
Subject: pull request for setup-storage
Date: Sat, 02 Aug 2014 00:12:26 +0200
Size: 1352
URL: <http://lists.uni-koeln.de/pipermail/linux-fai-devel/attachments/20140806/db7bf951/attachment.mht>


More information about the linux-fai-devel mailing list