Moved tests for dos.library functions into the 'dos' subdir.
[AROS.git] / rom / dos / deviceproc.c
blobf61eaa1e654325469b83927a70dc78195fd4ae0a
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: DeviceProc - Return a handle to a device's process.
6 Lang: english
7 */
8 #include "dos_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/dos.h>
15 AROS_LH1(struct MsgPort *, DeviceProc,
17 /* SYNOPSIS */
18 AROS_LHA(CONST_STRPTR, name, D1),
20 /* LOCATION */
21 struct DosLibrary *, DOSBase, 29, Dos)
23 /* FUNCTION
24 DeviceProc() is an obsolete function that returns the
25 MsgPort responsible for a DOS device.
27 DeviceProc() will fail if you ask for the MsgPort of a device
28 created with AssignPath() as there is no process to return.
29 If the device requested is an assign, the IoErr() will contain
30 the Lock to the directory (the function will return the device
31 on which the lock is set).
33 INPUTS
34 name - The name of the DOS device, INCLUDING the ':'.
36 RESULT
37 Either a pointer to the MsgPort, or NULL.
39 NOTES
40 You should really use GetDeviceProc(), as that function
41 returns a more useful structure (DevProc), that will
42 persist until FreeDeviceProc() is called on it.
44 EXAMPLE
46 BUGS
47 Does not support late- and non-bound assigns, or multiple
48 path assigns very well.
50 SEE ALSO
51 GetDeviceProc(), FreeDeviceProc()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 struct MsgPort *res;
60 struct DevProc *dvp;
61 SIPTR err;
63 /* just use GetDeviceProc(), it knows everything useful anyway */
64 if ((dvp = GetDeviceProc(name, NULL)) == NULL)
65 return NULL;
67 /* if GetDeviceProc() had to create the lock (ie non-binding assigns), we
68 * can't return it as there's no cleanup function, so we have to error */
69 if (dvp->dvp_Flags & DVPF_UNLOCK)
71 res = NULL;
72 err = ERROR_DEVICE_NOT_MOUNTED;
74 else
76 /* all good. get the lock and device */
77 res = dvp->dvp_Port;
78 err = (SIPTR)dvp->dvp_Lock;
81 FreeDeviceProc(dvp);
83 SetIoErr(err);
84 return res;
86 AROS_LIBFUNC_EXIT
87 } /* DeviceProc */