

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
19 messages in net.java.dev.jna.usersRe: Identifying symbolic links on Mac...| From | Sent On | Attachments |
|---|---|---|
| Timothy Wall | Dec 11, 2007 5:34 am | |
| Normen Müller | Dec 11, 2007 6:35 am | |
| Normen Müller | Dec 11, 2007 6:52 am | |
| Timothy Wall | Dec 11, 2007 7:20 am | |
| Timothy Wall | Dec 11, 2007 7:53 am | |
| Timothy Wall | Dec 11, 2007 7:55 am | |
| Nikolas Lotz | Dec 11, 2007 8:05 am | |
| Normen Müller | Dec 11, 2007 8:27 am | |
| Normen Müller | Dec 11, 2007 8:37 am | |
| Timothy Wall | Dec 11, 2007 10:25 am | |
| Duncan McGregor | Dec 11, 2007 3:05 pm | |
| Normen Müller | Dec 12, 2007 12:04 am | |
| Peter Reilly | Dec 12, 2007 1:34 am | |
| Normen Müller | Dec 12, 2007 1:39 am | |
| Timothy Wall | Dec 12, 2007 4:34 am | |
| Timothy Wall | Dec 12, 2007 4:38 am | |
| Normen Müller | Dec 12, 2007 4:57 am | |
| Normen Müller | Dec 12, 2007 5:04 am | |
| Timothy Wall | Dec 12, 2007 5:36 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: Identifying symbolic links on Mac OSX 10.5.1 | Actions... |
|---|---|---|
| From: | Normen Müller (n.mu...@jacobs-university.de) | |
| Date: | Dec 11, 2007 8:27:42 am | |
| List: | net.java.dev.jna.users | |
Timothy Wall <twalljava@...> writes:
On Dec 11, 2007, at 9:35 AM, Normen Müller wrote:
Timothy Wall <twalljava@...> writes:
Several things to look at: 1) how is the C library loaded? is it loaded properly on OSX (i.e. do you get an instance of ISVNCLibrary)?
Yes, I think so. In debug mode the debugger outputs
Proxy interface to Native Library </usr/lib/libc.dylib <at> 2414037576>
when I click on cLibrary in the line
ISVNCLibrary cLibrary = JNALibraryLoader.getCLibrary();
So you know the library lookup and load works. Good.
2) how is lstat defined on OSX 10.5.1? in glibc, it is a macro that points to _xstat
I have no clue about the definition of lstat on OSX 10.5.1, guess that's the real problem. I was hoping the SVNKit guys already did it right
A quick look at sys/stat.h shows a single declaration of lstat. If you don't get an UnsatisfiedLinkError when that method is invoked, then that symbol exists in the library. Also good.
I would recommend writing a small unit test program that reproduces the SVNKit code, then you can instrument it as needed to figure out where it is failing.
That's, what I am doing. Currently I am not using the whole SVNKit library but just testing this SVNLinuxUtil class:
synchronized (ourSharedMemory) { ourSharedMemory.clear(); int rc; synchronized (cLibrary) { rc = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? cLibrary.lstat(path, ourSharedMemory) : cLibrary.__lxstat64(0, path, ourSharedMemory); }
Check the return code here. Does it indicate an error?
The return code is zero, so it looks good.
if (rc < 0) { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; } int mode = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? ourSharedMemory.getInt(8) : ourSharedMemory.getInt(16);
Here's where you might get into trouble. SVNKit is just grabbing memory offsets from the stat structure (typically you'd probably want to define a structure representing the native structure, but in this case SVNKit is doing some quick and dirty lookups to get just what they need).
Yeah, I also think this is a bit dirty, and I would really like to clean up the code, but I don't know how to define the stat structure within Java.
The required offset depends on where the "mode_t st_mode" field shows up in the "stat" structure (see sys/stat.h). On darwin/bsd, the first two fields are 32 bits each, which gives you the 8 byte offset. This looks correct.
int type = mode & 0170000; if (type == 0120000) { return SVNFileType.SYMLINK; } else if (type == 0040000) { return SVNFileType.DIRECTORY; } else if (type == 0100000) { return SVNFileType.FILE; } else { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; }
Print out the actual mode read from memory, and double check the predefined constants to ensure they match the header file definitions.
At what point is the function returning "null"? Does it work for FILE? does it work for DIRECTORY? does it work for SYMLINK?
No, it doesn't work at all.
I was looking at /Developer/SDKs/MacOSX10.5.sdk/usr/include/sys/stat.h and found the following (maybe one can read this, cause I am not so familiar with C):
[...] #define __DARWIN_STRUCT_STAT64 { \ dev_t st_dev; /* [XSI] ID of device containing file */ \ mode_t st_mode; /* [XSI] Mode of file (see below) */ \ nlink_t st_nlink; /* [XSI] Number of hard links */ \ __darwin_ino64_t st_ino; /* [XSI] File serial number */ \ uid_t st_uid; /* [XSI] User ID of the file */ \ gid_t st_gid; /* [XSI] Group ID of the file */ \ dev_t st_rdev; /* [XSI] Device ID */ \ __DARWIN_STRUCT_STAT64_TIMES \ off_t st_size; /* [XSI] file size, in bytes */ \ blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \ blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \ __uint32_t st_flags; /* user defined flags for file */ \ __uint32_t st_gen; /* file generation number */ \ __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \ __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \ } [...] #if __DARWIN_64_BIT_INO_T
struct stat __DARWIN_STRUCT_STAT64;
#else /* !__DARWIN_64_BIT_INO_T */
struct stat { dev_t st_dev; /* [XSI] ID of device containing file */ ino_t st_ino; /* [XSI] File serial number */ mode_t st_mode; /* [XSI] Mode of file (see below) */ nlink_t st_nlink; /* [XSI] Number of hard links */ uid_t st_uid; /* [XSI] User ID of the file */ gid_t st_gid; /* [XSI] Group ID of the file */ dev_t st_rdev; /* [XSI] Device ID */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) struct timespec st_atimespec; /* time of last access */ struct timespec st_mtimespec; /* time of last data modification */ struct timespec st_ctimespec; /* time of last status change */ #else time_t st_atime; /* [XSI] Time of last access */ long st_atimensec; /* nsec of last access */ time_t st_mtime; /* [XSI] Last data modification time */ long st_mtimensec; /* last data modification nsec */ time_t st_ctime; /* [XSI] Time of last status change */ long st_ctimensec; /* nsec of last status change */ #endif off_t st_size; /* [XSI] file size, in bytes */ blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ __uint32_t st_flags; /* user defined flags for file */ __uint32_t st_gen; /* file generation number */ __int32_t st_lspare; /* RESERVED: DO NOT USE! */ __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ }; [...] /* * [XSI] The following are symbolic names for the values of type mode_t. They * are bitmap values. */ #ifndef S_IFMT /* File type */ #define S_IFMT 0170000 /* [XSI] type of file mask */ #define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */ #define S_IFCHR 0020000 /* [XSI] character special */ #define S_IFDIR 0040000 /* [XSI] directory */ #define S_IFBLK 0060000 /* [XSI] block special */ #define S_IFREG 0100000 /* [XSI] regular */ #define S_IFLNK 0120000 /* [XSI] symbolic link */ #define S_IFSOCK 0140000 /* [XSI] socket */ #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #define S_IFWHT 0160000 /* whiteout */ #define S_IFXATTR 0200000 /* extended attribute */ #endif







