virtual_oss(8) checks if cuse(3) is loaded. However, kldload(2) ends up calling
kern_kldload that checks permissions first. It is only later on in
linker_load_module that -EEXIST is returned if the module is already loaded.
That means that users that can't load modules, always get a -EPERM error even if
cuse.ko is already loaded and ready to use.
$ kldstat | grep cuse 2 1 0xffffffff8233a000 c148 cuse.ko $ virtual_oss virtual_oss: Failed to load cuse kernel module: Operation not permitted $
Change it to check if the kernel module is already loaded and try load it if it
isn't.
In addition move the program's arguments parsing early on because otherwise, a
user can't even access the program's help if cuse.ko is not loaded and the
user doesn't have permissions to do it.