I have attempted to make a script that creates a file and then sets it as immutable similar to the chattr +i command for linux. The script compiles
The main problem is that the ioctl wants a pointer to the mask, not a direct constant. You have to define a int variable, store the mask (0x10) in it and pass its address as third argument of ioctl.
Also, I'd add some hints:
O_RDONLY. FS_IMMUTABLE_FL istead the raw constant. FS_IOC_SETFLAGS) and mask it with the new flag, so other settings are not lost by the service.