diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-14 06:59:24 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-10 18:40:19 +1000 |
commit | b8ba0563f25d5ac40d80718d5d05503c27806765 (patch) | |
tree | 94fd1d65df8171582b63db19b58580e2d22936ae | |
parent | 67129af6419e1e839f2a34811173b27342c8e40d (diff) | |
download | busybox-w32-b8ba0563f25d5ac40d80718d5d05503c27806765.tar.gz busybox-w32-b8ba0563f25d5ac40d80718d5d05503c27806765.tar.bz2 busybox-w32-b8ba0563f25d5ac40d80718d5d05503c27806765.zip |
win32: add link()
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | win32/mingw.c | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h index 0ff7f5442..40c11aabf 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -256,7 +256,7 @@ NOIMPL(fcntl,int fd UNUSED_PARAM, int cmd UNUSED_PARAM, ...); | |||
256 | #define fork() -1 | 256 | #define fork() -1 |
257 | IMPL(fsync,int,0,int fd UNUSED_PARAM); | 257 | IMPL(fsync,int,0,int fd UNUSED_PARAM); |
258 | NOIMPL(kill,pid_t pid UNUSED_PARAM, int sig UNUSED_PARAM); | 258 | NOIMPL(kill,pid_t pid UNUSED_PARAM, int sig UNUSED_PARAM); |
259 | NOIMPL(link,const char *oldpath UNUSED_PARAM, const char *newpath UNUSED_PARAM); | 259 | int link(const char *oldpath, const char *newpath); |
260 | NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); | 260 | NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); |
261 | int pipe(int filedes[2]); | 261 | int pipe(int filedes[2]); |
262 | NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); | 262 | NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); |
diff --git a/win32/mingw.c b/win32/mingw.c index afd017e87..eccd37cc3 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -327,3 +327,24 @@ sighandler_t mingw_signal(int sig, sighandler_t handler) | |||
327 | timer_fn = handler; | 327 | timer_fn = handler; |
328 | return old; | 328 | return old; |
329 | } | 329 | } |
330 | |||
331 | int link(const char *oldpath, const char *newpath) | ||
332 | { | ||
333 | typedef BOOL WINAPI (*T)(const char*, const char*, LPSECURITY_ATTRIBUTES); | ||
334 | static T create_hard_link = NULL; | ||
335 | if (!create_hard_link) { | ||
336 | create_hard_link = (T) GetProcAddress( | ||
337 | GetModuleHandle("kernel32.dll"), "CreateHardLinkA"); | ||
338 | if (!create_hard_link) | ||
339 | create_hard_link = (T)-1; | ||
340 | } | ||
341 | if (create_hard_link == (T)-1) { | ||
342 | errno = ENOSYS; | ||
343 | return -1; | ||
344 | } | ||
345 | if (!create_hard_link(newpath, oldpath, NULL)) { | ||
346 | errno = err_win_to_posix(GetLastError()); | ||
347 | return -1; | ||
348 | } | ||
349 | return 0; | ||
350 | } | ||