aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-14 06:59:24 +0200
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-20 19:14:04 +0200
commitfa7ad8d569d33a54c02c9db9160f5e17f8438566 (patch)
tree3f250b4e5792e465468c9be9852eb3bae3a5e4f4
parent86167803e83ffb2b799876269bb4439192e964b3 (diff)
downloadbusybox-w32-fa7ad8d569d33a54c02c9db9160f5e17f8438566.tar.gz
busybox-w32-fa7ad8d569d33a54c02c9db9160f5e17f8438566.tar.bz2
busybox-w32-fa7ad8d569d33a54c02c9db9160f5e17f8438566.zip
win32: add link()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
-rw-r--r--include/mingw.h2
-rw-r--r--win32/mingw.c21
2 files changed, 22 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h
index c26e16bc7..963a87104 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -258,7 +258,7 @@ NOIMPL(fcntl,int fd UNUSED_PARAM, int cmd UNUSED_PARAM, ...);
258#define fork() -1 258#define fork() -1
259IMPL(fsync,int,0,int fd UNUSED_PARAM); 259IMPL(fsync,int,0,int fd UNUSED_PARAM);
260NOIMPL(kill,pid_t pid UNUSED_PARAM, int sig UNUSED_PARAM); 260NOIMPL(kill,pid_t pid UNUSED_PARAM, int sig UNUSED_PARAM);
261NOIMPL(link,const char *oldpath UNUSED_PARAM, const char *newpath UNUSED_PARAM); 261int link(const char *oldpath, const char *newpath);
262NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); 262NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM);
263int pipe(int filedes[2]); 263int pipe(int filedes[2]);
264NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); 264NOIMPL(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
331int 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}