summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libunix/link.c
blob: 4550c76c94d9b2c2d3c961dc65c99d59baca2c64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* link.c
   Link two files.  */

#include "uucp.h"

#include "uudefs.h"
#include "sysdep.h"
#include "system.h"

#include <errno.h>

boolean
fsysdep_link (zfrom, zto, pfworked)
     const char *zfrom;
     const char *zto;
     boolean *pfworked;
{
  *pfworked = FALSE;
  if (link (zfrom, zto) == 0)
    {
      *pfworked = TRUE;
      return TRUE;
    }
  if (errno == ENOENT)
    {
      if (! fsysdep_make_dirs (zto, TRUE))
	return FALSE;
      if (link (zfrom, zto) == 0)
	{
	  *pfworked = TRUE;
	  return TRUE;
	}
    }
  if (errno == EXDEV)
    return TRUE;
  ulog (LOG_ERROR, "link (%s, %s): %s", zfrom, zto, strerror (errno));
  return FALSE;
}