Re: how to detect a hard link in Java?



jojo wrote:
I have an application need to detect the hard links within the unix
file systems. how to detect it and how to get the target path of this
link points to in Java?
thanks a lot

You can either Runtime.exec("/bin/ls -il "+filename) and parse the result, or grab a package like

http://www.bmsi.com/java/posix/package.html

which includes Posix.stat() to get the inode and the number of links
for a file or directory.

Files with more than one link are hard links.  What it points to is
an inode.  You pretty much have to search the file system for another
hard link with the same inode number.
.



Relevant Pages

  • Re: Kernel SCM saga..
    ... On filesystems that don't have a stable inode number, I use the md5sum ... Since these same file systems lack hard links as ... It works with smb, fat, vfat, ...
    (Linux-Kernel)
  • Re: [UNIONFS] 00/42 Unionfs and related patches review
    ... When stackable file systems were first proposed in the early 90s, ... data changes will happen on a lower inode all within one second and not be ... What you propose violates the clean layer separation in a way that I'm not ...
    (Linux-Kernel)
  • Re: kern/85503: panic: wrong dirclust using msdosfs in RELENG_6
    ... Tricks to map to the API's inode number space are unavoidable due to ... representing offsets within file systems. ... I think I said that the inode number in msdosfs should be the cluster ...
    (freebsd-arch)
  • Re: simplifying linux_emul_convpath()
    ... > The problem is with archivers. ... > the inode are equal then its the same file. ... > archivers that can store hard links will think that this is a hard link ... > So backups of these larger file systems will likely be hosed. ...
    (freebsd-current)
  • Re: simplifying linux_emul_convpath()
    ... > RW>playing games with inode numbers, device ids, etc. ... the existence of globally scalable distributed file systems. ... reality is that the very large scalable file systems hash larger ... it used inode numbers internally in the VFS quite a bit. ...
    (freebsd-current)