4 messages in net.java.dev.jna.usersRe: [jna-users] Unable to link to sta...
FromSent OnAttachments
Kevin BurtonMar 25, 2009 5:39 pm 
Daniel KaufmannMar 25, 2009 6:00 pm 
Kevin BurtonMar 25, 2009 7:09 pm 
Kevin BurtonMar 25, 2009 7:15 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Unable to link to stat.....Actions...
From:Kevin Burton (bur@spinn3r.com)
Date:Mar 25, 2009 7:15:41 pm
List:net.java.dev.jna.users

The error I get is: file error: Invalid argument

Kevin

Interesting...... still not working though. Here's the function def:

extern int __xstat (int __ver, __const char *__filename, struct stat *__stat_buf) __THROW __nonnull ((2, 3));

but this:

int __xstat( int ver, String path, stat.StatStructure stat );

Doesn't actually fix the problem.

On Wed, Mar 25, 2009 at 6:01 PM, Daniel Kaufmann <dani@gmail.com>wrote:

This has being previously posted on the list. Please check this thread: https://jna.dev.java.net/servlets/ReadMsg?list=users&msgNo=712

On Wed, Mar 25, 2009 at 8:39 PM, Kevin Burton <bur@spinn3r.com> wrote:

OK.... I'm currently running into this bug.

On OS X I have a stat() function which works. It doesn't work on Linux.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'stat': /lib/libc.so.6: undefined symbol: stat at com.sun.jna.Function.<init>(Function.java:129) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:250) at com.sun.jna.Library$Handler.invoke(Library.java:191) at posix.$Proxy0.stat(Unknown Source) at posix.stat.stat(stat.java:184) at posix.Example.main(Example.java:23)

..... I'm working on a posix compat library to call some important posix functions.

This on is mkfifo + stat (stat is needed to verify that it IS a fifo).

Here's what my code looks like:

private static StatInterface delegate = (StatInterface)Native.loadLibrary( "c", StatInterface.class);

public static class StatStructure extends Structure {

public long st_dev; /* ID of device containing file */ public long st_ino; /* inode number */ public long st_mode; /* protection */ public long st_nlink; /* number of hard links */ public long st_uid; /* user ID of owner */ public long st_gid; /* group ID of owner */ public long st_rdev; /* device ID (if special file) */ public long st_size; /* total size, in bytes */ public long st_blksize; /* blocksize for filesystem I/O */ public long st_blocks; /* number of blocks allocated */ public long st_atime; /* time of last access */ public long st_mtime; /* time of last modification */ public long st_ctime; /* time of last status change */

}

public static int stat(String path, stat.StatStructure stat ) { return delegate.stat( path, stat ); }

}

interface StatInterface extends Library {

int mkfifo( String pathname, int mode_t ); int unlink( String path ); int chmod( String path, int mode_t ); int stat( String path, stat.StatStructure stat ); }