W.I.P AROS port of SDI examples
[AROS.git] / rom / filesys / cdfs / cdfs.h
blob154fcd369632c702d4b425b777ebdbe0088cbdf4
1 /*
2 * Copyright (C) 2013, The AROS Development Team
3 * All right reserved.
4 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
6 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
7 */
9 #ifndef CDFS_H
10 #define CDFS_H
12 #include <exec/execbase.h>
13 #include <dos/dosextens.h>
15 struct BCache;
16 struct CDFSDevice;
18 #ifndef ARRAY_SIZE
19 #define ARRAY_SIZE(x) ((sizeof(x)/sizeof((x)[0])))
20 #endif
22 struct CDFS {
23 struct SignalSemaphore cb_Semaphore; /* Master CD controller */
24 struct ExecBase *cb_SysBase;
25 struct Library *cb_UtilityBase;
27 struct List cb_Devices;
28 struct List cb_Volumes;
31 /* Allocated by the volume - CDFS does not alloc nor free it! */
32 struct CDFSLock {
33 struct MinNode cl_Node; /* For use by CDFS */
34 struct FileLock cl_FileLock; /* fl_Key must be unique per file - set by filesystem */
35 struct FileInfoBlock cl_FileInfoBlock;
36 /* Private filesystem data follows */
39 #undef container_of
40 #define container_of(ptr, type, member) ({ \
41 const typeof(((type *)0)->member) *__mptr = (ptr); \
42 (type *)((char *)__mptr - offsetof(type, member)); })
45 #define B_LOCK(x) (((BPTR)(x) == BNULL) ? NULL : container_of(BADDR(x), struct CDFSLock, cl_FileLock))
46 #define MKB_LOCK(x) MKBADDR(&(x)->cl_FileLock)
48 struct CDFSVolume;
50 struct CDFSOps {
51 LONG op_Type;
52 LONG (*op_Mount)(struct CDFSVolume *vol);
53 LONG (*op_Unmount)(struct CDFSVolume *vol);
55 LONG (*op_Locate)(struct CDFSVolume *vol, struct CDFSLock *ilock, CONST_STRPTR file, ULONG mode, struct CDFSLock **nlock);
56 VOID (*op_Close)(struct CDFSVolume *vol, struct CDFSLock *ilock);
57 LONG (*op_ExamineNext)(struct CDFSVolume *vol, struct CDFSLock *ifile, struct FileInfoBlock *fib);
58 LONG (*op_Seek)(struct CDFSVolume *vol, struct CDFSLock *ifile, SIPTR pos, LONG mode, SIPTR *oldpos);
59 LONG (*op_Read)(struct CDFSVolume *vol, struct CDFSLock *ifile, APTR buff, SIPTR len, SIPTR *actual);
62 struct CDFSVolume {
63 struct MinNode cv_Node;
64 struct DeviceList cv_DosVolume; /* ISOFS: dl_VolumeDate, dl_VolumeType, dl_Name */
65 struct CDFS *cv_CDFSBase; /* CDFS: Main reference */
66 struct CDFSDevice *cv_Device; /* CDFS: Current device */
67 struct List cv_FileLocks; /* CDFS: Lock list */
68 struct InfoData cv_InfoData; /* ISOFS: Data about filesystem */
69 const struct CDFSOps *cv_Ops; /* ISOFS: Operations */
70 APTR cv_Private; /* ISOFS: Volume private data */
73 #define B_VOLUME(x) (((BPTR)(x) == BNULL) ? NULL : container_of(BADDR(x), struct CDFSVolume, cv_DosVolume))
74 #define MKB_VOLUME(x) MKBADDR(&(x)->cv_DosVolume)
77 struct CDFSDevice {
78 struct MinNode cd_Node;
79 struct BCache *cd_BCache;
80 struct CDFSVolume *cd_Volume; /* NULL if no volume is present */
84 #define SysBase (cdfs->cb_SysBase)
85 #define UtilityBase (cdfs->cb_UtilityBase)
87 LONG CDFS_Handler(struct ExecBase *sysBase);
89 #endif /* CDFS_H */