commit 7ac49e29cafbf579608560206f62580078197b2f Author: Matthew Booth Date: Mon Jun 28 15:24:50 2010 +0100 Device_map: new lens for grub's device.map diff --git a/lenses/device_map.aug b/lenses/device_map.aug new file mode 100644 index 0000000..090edd5 --- /dev/null +++ b/lenses/device_map.aug @@ -0,0 +1,28 @@ +(* Parsing grub's device.map *) + +module Device_map = + autoload xfm + + let sep_tab = Sep.tab + let eol = Util.eol + let fspath = Rx.fspath + let del_str = Util.del_str + + let comment = Util.comment + let empty = Util.empty + + let dev_name = /(h|f|c)d[0-9]+(,[0-9a-zA-Z]+){0,2}/ + let dev_hex = /0x[0-9a-fA-F]+/ + let dev_dec = /[0-9]+/ + + let device = del_str "(" . key ( dev_name | dev_hex | dev_dec ) . del_str ")" + + let map = [ device . sep_tab . store fspath . eol ] + + let lns = ( empty | comment | map ) * + + let xfm = transform lns (incl "/boot/grub/device.map") + +(* Local Variables: *) +(* mode: caml *) +(* End: *) diff --git a/lenses/tests/test_device_map.aug b/lenses/tests/test_device_map.aug new file mode 100644 index 0000000..2a7810a --- /dev/null +++ b/lenses/tests/test_device_map.aug @@ -0,0 +1,34 @@ +module Test_device_map = + + let conf = "# this device map was generated by anaconda +(fd0) /dev/fda +(hd0) /dev/sda +(cd0) /dev/cdrom +(hd1,1) /dev/sdb1 +(hd0,a) /dev/sda1 +(0x80) /dev/sda +(128) /dev/sda +" + + test Device_map.lns get conf = + { "#comment" = "this device map was generated by anaconda" } + { "fd0" = "/dev/fda" } + { "hd0" = "/dev/sda" } + { "cd0" = "/dev/cdrom" } + { "hd1,1" = "/dev/sdb1" } + { "hd0,a" = "/dev/sda1" } + { "0x80" = "/dev/sda" } + { "128" = "/dev/sda" } + + test Device_map.lns put conf after + set "hd2,1" "/dev/sdb1" + = "# this device map was generated by anaconda +(fd0) /dev/fda +(hd0) /dev/sda +(cd0) /dev/cdrom +(hd1,1) /dev/sdb1 +(hd0,a) /dev/sda1 +(0x80) /dev/sda +(128) /dev/sda +(hd2,1)\t/dev/sdb1 +" diff --git a/tests/Makefile.am b/tests/Makefile.am index 1e20743..3570c53 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,6 +23,7 @@ lens_tests = \ lens-cron.sh \ lens-darkice.sh \ lens-debctrl.sh \ + lens-device_map.sh \ lens-dhclient.sh \ lens-dnsmasq.sh \ lens-dpkg.sh \