-3

Is it true that --link-dest=DIR of rsync only take an absolute pathname for DIR, and relative pathname for DIR doesn't work?

When I run

rsync -a --delete --link-dest=dest my\ dir  dest2/
rsync -a --delete --link-dest=./dest my\ dir  dest2/

identical files in source my\ dir and dest or ./dest are copied into destination directory dest2.

When I run

rsync -a --delete --link-dest=/tmp/test/backup/dest my\ dir  dest2/

identical files in source my\ dir and /tmp/test/backup/dest are hard linked from /tmp/test/backup/dest to destination directory dest2


If my guess is true, then how is rsync implemented to take only an absolute path for --link-dest?

Is it correct that all the functions in Linux API, if they take pathname arguments, their pathnames arguments can be either of absolute and relative pathnames?

Thanks.

3

Quoting the rsync manpage’s description of --link-dest:

If DIR is a relative path, it is relative to the destination directory.

Thus you can use relative paths, relative to the destination directory.

I’m not sure what the “Linux API” (I’m guessing you’re referring to the userspace API provided by the kernel) has to do with this, rsync isn’t a Linux-specific tool. However, most if not all calls which accept paths can take absolute and relative pathnames; in the latter case, the paths are usually relative to the current directory or to a provided file descriptor (in the ...at calls, e.g. openat). (I haven’t checked all the calls.)

  • Thanks. "I’m not sure what the “Linux API” (I’m guessing you’re referring to the userspace API provided by the kernel) has to do with this". On Linux, isn't rsync implemented based on Linux API? – Tim May 17 '18 at 20:45
  • Ultimately yes, rsync on Linux is implemented on top of the Linux API (like any program running on Linux). However I don’t think it was designed on top of the Linux API, and it’s not developed on top of the Linux API — it’s designed with a certain feature set, and developed using the C standard library. – Stephen Kitt May 17 '18 at 21:05
  • Thanks for clarifcation. (1) I can't find openat in the standard C library. Is openat in Linux API only? What function in the standard C library does rsync call explicitly in place of openat? (2) What are other ...at calls besides openat in either Linux API or the C standard library? – Tim May 17 '18 at 21:09
  • openat is defined by POSIX; note that I only gave that as an example of functions taking a file descriptor for the base of relative paths, rsync’s --link-dest doesn’t use anything like that. The other ...at functions are faccessat, fchownat, fstatat, linkat, mkdirat, mkfifoat, mknodat, readlinkat, renameat, symlinkat, and unlinkat. – Stephen Kitt May 17 '18 at 21:29
  • Thanks. Wondering how you found the *at functions? Can I grep it somewhere? – Tim May 17 '18 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.