URL: http://svn.opensuse.org/viewcvs/yast?rev=62759&view=rev Log: update fstab options (bnc#649497)
@@ -5178,6 +5178,25 @@ } }
+global define void UpdateFstabOptions() { + y2milestone( "UpdateFstabOptions" ); + string tabpath = PathToDestdir( "/etc/fstab" ); + map fstab = Partitions::GetFstab( tabpath ); + integer line = 0; + string n = ""; + while( line<=AsciiFile::NumLines( fstab ) ) + { + map l = AsciiFile::GetLine( fstab, line ); + string options = l["fields", 3]:""; + if (regexpmatch (options, "^\(.*,\)\?hotplug\(,.*\)\?$")) { + options = regexpsub (options, "^\(.*,\)\?hotplug\(,.*\)\?$", "\\1nofail\\2"); + AsciiFile::ChangeLineField( fstab, line, 3, options ); + } + line = line+1; + } + AsciiFile::RewriteFile( fstab, tabpath ); +} +
My new favorite hammer can do this in one line ;-) int aug_setm(augeas *aug, const char *base, const char *sub, const char *value) aug_setm(context, "/files/etc/fstab/*/opt[. = 'hotplug']", NULL, "nofail"); Or in Ruby: http://git.fedorahosted.org/git/?p=ruby-augeas.git;a=blobdiff;f=tests/tc_aug... -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu