static char sccsid
[] = "@(#)ln.c 4.5 %G%";
int fflag
; /* force flag set? */
if (argc
&& strcmp(argv
[0], "-f") == 0) {
if (argc
&& strcmp(argv
[0], "-s") == 0) {
if (sflag
== 0 && argc
> 2) {
if (stat(argv
[argc
-1], &stb
) < 0)
if ((stb
.st_mode
&S_IFMT
) != S_IFDIR
)
for(i
= 0; i
< argc
-1; i
++)
r
|= linkit(argv
[i
], argv
[argc
-1]);
fprintf(stderr
, "Usage: ln [ -s ] f1\nor: ln [ -s ] f1 f2\nln [ -s ] f1 ... fn d2\n");
int (*linkf
)() = sflag
? symlink
: link
;
/* is target a directory? */
if (sflag
== 0 && fflag
== 0 && stat(from
, &stb
) >= 0
&& (stb
.st_mode
&S_IFMT
) == S_IFDIR
) {
printf("%s is a directory\n", from
);
if (stat(to
, &stb
) >= 0 && (stb
.st_mode
&S_IFMT
) == S_IFDIR
) {
tail
= rindex(from
, '/');
sprintf(name
, "%s/%s", to
, tail
);
if ((*linkf
)(from
, to
) < 0) {
else if (access(from
, 0) < 0)