rtapi_open_as_root.3rtapi
1 .TH rtapi_open_as_root "3rtapi" "" "LinuxCNC Documentation" "RTAPI" 2 .SH NAME 3 4 rtapi_open_as_root \- Open a file with "root" privilege 5 6 .SH SYNTAX 7 .nf 8 .B #include <rtapi.h> 9 .HP 10 .BI "int rtapi_open_as_root(const char " *filename ", int " "flags)" 11 .fi 12 .SH ARGUMENTS 13 .IP \fIfilename\fR 14 The filename to open, as in \fBopen(2)\fR. Note that rtapi has no well-defined 15 "current directory", so this should be an absolute path, but this is not 16 enforced. 17 .IP \fIflags\fR 18 The open flags, as in \fBopen(2)\fR. Should never include bits that open or 19 create files (e.g., O_CREAT, O_APPEND, etc) as this API is not intended for 20 creating or writing files, but this is not enforced. 21 22 .SH DESCRIPTION 23 In "uspace" realtime, root privileges are dropped whenever possible. This API 24 temporarily switches on root priveleges to open a file, and switches them 25 off before returning. This can be useful for example when accessing device 26 nodes or memory-mapped I/O. 27 28 In the case of PCI devices on x86 and x86-64 systems, prefer the linux-style 29 PCI interfaces provided in \fB<rtapi_pci.h>\fR. 30 31 .SH RETURN VALUE 32 In case of success, the nonnegative file descriptor opened. If the caller does 33 not close it, it remains open until rtapi_app exits. 34 35 In case of failure, a negative errno value. 36 37 .SH REALTIME CONSIDERATIONS 38 Call only from realtime initcode in "uspace" realtime. 39 40 .SH SEE ALSO 41 \fBopen(2)\fR, \fBrtapi_pci(3)\fR