1

i want to use the file io functions (open, read, write) and the pseudo-terminal(http://linux.die.net/man/4/pts) functions (grantpt, unlockpt, ptsname) from mono.

translating the arguments and return values is trivial (still, i would appreciate it if you could verify them) but i can't find the corresponding librarys.

My linux distribution is Arch Linux on ARM (Raspberry PI). As the ARM Platform is only 32-Bit, i can just use int32 for int/size_t, etc

Thank you very much.

internal class LinuxNativeMethods
{
    //int open(const char *pathname, int flags);
    [DllImport("??.so")]
    internal extern int open(string name, int flags);

    //ssize_t read(int fd, void *buf, size_t count);
    [DllImport("??.so")]
    internal extern int read(int fd, byte[] buffer, int length);

    //ssize_t write(int fd, const void *buf, size_t count); 
    [DllImport("??.so")]
    internal extern int write(int fd, byte[] buffer, int length);

    //int grantpt(int fd);
    [DllImport("??.so")]
    internal extern int grantpt(int fd);

    //int unlockpt(int fd);
    [DllImport("??.so")]
    internal extern int unlockpt(int fd);

    //i later marshall the pointer to a string
    //char *ptsname(int fd);
    [DllImport("??.so")]
    internal extern IntPtr ptsname(int fd);
}
Lukas Rieger
  • 676
  • 10
  • 31
  • How is your problem related to pinvoke? You just can't figure out the library names, that has nothing to do with P/Invoke. – antonijn Apr 09 '13 at 11:03

1 Answers1

1

The functions appear to be in glibc, so the dllimport would look something like this:

[DllImport("libc.so.6")]
antonijn
  • 5,702
  • 2
  • 26
  • 33