2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Create a hard- or softlink.
8 #include <dos/dosextens.h>
9 #include <dos/filesystem.h>
10 #include "dos_intern.h"
11 #include <proto/exec.h>
13 /*****************************************************************************
16 #include <exec/types.h>
17 #include <proto/dos.h>
19 AROS_LH3(LONG
, MakeLink
,
22 AROS_LHA(STRPTR
, name
, D1
),
23 AROS_LHA(APTR
, dest
, D2
),
24 AROS_LHA(LONG
, soft
, D3
),
27 struct DosLibrary
*, DOSBase
, 74, Dos
)
30 MakeLink() will create a link between two files or directories.
31 A link is a filesystem object that refers to another file.
33 A soft link refers to another file by name, and is resolved by
34 the filesystem and the caller. Soft links are not restricted to
35 the same volume. The |dest| argument is a NUL terminated pathname
36 to the pre-existing object. Soft links can be used on directories.
38 A hard link refers to another file by the location on a disk, and
39 is resolved by the filesystem. Hard links are restricted to files
40 on the same volume. The |dest| argument is a lock on another file.
43 name - The name of the link to create
44 dest - If 'soft' is TRUE this must be a filename, if it is FALSE a BPTR
45 pointing to the file to be hard-linked must be provided
46 soft - TRUE, if a soft-link is to be created, FALSE for an hard-link
49 boolean - DOSTRUE or DOSFALSE. On error, IoErr() will contain more
57 Soft links were not working in the ROM filesystem before version
64 This function calls either FSA_CREATE_HARDLINK or FSA_CREATE_SOFTLINK
65 on the filesystem of `name`.
67 *****************************************************************************/
70 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
73 struct Process
*me
=(struct Process
*)FindTask(NULL
);
76 io
.IOFS
.io_Message
.mn_Node
.ln_Type
= NT_REPLYMSG
;
77 io
.IOFS
.io_Message
.mn_ReplyPort
= &me
->pr_MsgPort
;
78 io
.IOFS
.io_Message
.mn_Length
= sizeof(struct IOFileSys
);
82 /* We want a soft-link. */
83 io
.IOFS
.io_Command
= FSA_CREATE_SOFTLINK
;
84 io
.io_Union
.io_CREATE_SOFTLINK
.io_Reference
= (STRPTR
)dest
;
87 /* We want a hard-link. */
88 struct FileHandle
*fh
= (struct FileHandle
*)BADDR((BPTR
)dest
);
89 /* We check, if name and dest are on the same device. */
90 if (DevName(name
, &dev
, DOSBase
))
92 if (dev
!= fh
->fh_Device
)
94 SetIoErr(ERROR_RENAME_ACROSS_DEVICES
);
97 io
.IOFS
.io_Command
= FSA_CREATE_HARDLINK
;
98 io
.io_Union
.io_CREATE_HARDLINK
.io_OldFile
= fh
->fh_Unit
;
101 error
= DoName(&io
, name
, DOSBase
);