Page MenuHomeFreeBSD

libucl-based configuration file parser for ctld
ClosedPublic

Authored by jceel on Dec 12 2015, 3:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 25 2023, 12:58 AM
Unknown Object (File)
Dec 25 2023, 12:58 AM
Unknown Object (File)
Dec 25 2023, 12:58 AM
Unknown Object (File)
Dec 23 2023, 12:04 PM
Unknown Object (File)
Nov 13 2023, 3:59 AM
Unknown Object (File)
Nov 9 2023, 1:20 AM
Unknown Object (File)
Sep 26 2023, 11:05 AM
Unknown Object (File)
Sep 2 2023, 3:29 PM
Subscribers

Details

Summary

This change adds additional, libucl-based configuration file parser to ctld. Parsing ctl.conf (or configuration file specified with -f) as an UCL file is enabled using -u command-line switch.

Test Plan

Example config file (which is actually in JSON format, fully compatible with UCL):

{
    "target": {
        "naa.5000c50006815e48": {
            "port": "camsim",
            "lun": [
                {
                    "number": 0,
                    "name": "disk1"
                },
                {
                    "number": 1,
                    "name": "disk3"
                },
                {
                    "number": 2,
                    "name": "disk4"
                }
            ]
        }
    },
    "lun": {
        "disk1": {
            "serial": "00505625139600",
            "blocksize": 512,
            "options": {
                "removable": "on",
                "product": "Virtual Disk",
                "vendor": "FreeNAS",
                "device-id": "Virtual Disk 00505625139600",
                "rpm": "7200",
                "naa": "0x6589cfc000000572122b119a12bbdac3"
            },
            "path": "/var/db/system/simulator/disk1"
        },
        "disk3": {
            "serial": "00505625139600",
            "blocksize": 512,
            "options": {
                "removable": "on",
                "product": "Virtual Disk",
                "vendor": "FreeNAS",
                "device-id": "Virtual Disk 00505625139600",
                "rpm": "7200",
                "naa": "0x6589cfc000000446222150ce63317d41"
            },
            "path": "/var/db/system/simulator/disk3"
        },
        "disk4": {
            "serial": "00505625139600",
            "blocksize": 512,
            "options": {
                "removable": "on",
                "product": "Virtual Disk",
                "vendor": "FreeNAS",
                "device-id": "Virtual Disk 00505625139600",
                "rpm": "7200",
                "naa": "0x6589cfc000000e7f80ec91885d4d80b9"
            },
            "path": "/var/db/system/simulator/disk4"
        },
        "disk2": {
            "serial": "00505625139600",
            "blocksize": 512,
            "options": {
                "removable": "on",
                "product": "Virtual Disk",
                "vendor": "FreeNAS",
                "device-id": "Virtual Disk 00505625139600",
                "rpm": "7200",
                "naa": "0x6589cfc000000ee13371ddb41ec93d01"
            },
            "path": "/var/db/system/simulator/disk2"
        }
    }
}

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jceel retitled this revision from to libucl-based configuration file parser for ctld.
jceel updated this object.
jceel edited the test plan for this revision. (Show Details)
jceel added a reviewer: trasz.
jceel set the repository for this revision to rS FreeBSD src repository - subversion.

Initialize "tag" variable to NULL explicitly at uclparse.c:134.

usr.sbin/ctld/Makefile
5

This kind of looks like like it should be handled by LIBADD=ucl. Isn't it?

usr.sbin/ctld/ctld.c
2553

I liked the old order, ie check_perms after parse_conf/uclparse_conf. This way you would get an user-friendly error with path, if the configuration file doesn't exist.

2556

style(9) - superfluous "{}" bracees.

usr.sbin/ctld/uclparse.c
228

s/parse_toplevel/uclparse_toplevel/ ?

472

Empty line.

660

Unneeded braces.

693

Braces.

jceel removed rS FreeBSD src repository - subversion as the repository for this revision.

Style fixes; moved check_perms() after parse_conf()/uclparse_conf().

trasz edited edge metadata.
This revision is now accepted and ready to land.Jan 26 2016, 4:46 PM
This revision was automatically updated to reflect the committed changes.