- Implemented execp*.
[planlOS.git] / system / include / fs / request.h
bloba93522ab3e940070c966acf05257b59b27f1cfd2
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 /**
22 * \file request.h
23 * Raw file system request functions.
26 #ifndef FS_REQUEST_H_INCLUDED
27 #define FS_REQUEST_H_INCLUDED
29 #include "fs/fs.h"
30 #include "ke/spinlock.h"
31 #include "ke/thread.h"
33 /**
34 * File system request type
36 typedef enum
38 FS_REQUEST_READ,
39 FS_REQUEST_WRITE,
40 FS_REQUEST_SEEK,
41 FS_REQUEST_IOCTL,
42 FS_REQUEST_OPEN,
43 FS_REQUEST_CLOSE,
44 FS_REQUEST_MKNOD,
45 FS_REQUEST_IOCTLSIZE
46 } FsRequestType;
48 /**
49 * File system request
51 typedef struct FsRequest
53 /**
54 * Request type.
56 FsRequestType type;
57 /**
58 * Target file system.
60 FsFileSystem *fs;
61 /**
62 * Target file. Can only be 0 for FS_REQUEST_OPEN and FS_REQUEST_MKNOD.
64 FsFile *file;
65 /**
66 * Generic flags for the file system request.
68 uint32_t flags;
70 /**
71 * Size of the request buffer.
73 uint32_t bufferlength;
74 /**
75 * Request buffer for data transmission.
77 void *buffer;
79 /**
80 * Offset for read/write and seek operations.
82 int64_t offset;
83 /**
84 * Origin for seek operations. 0 means start of the file, 2 means end
86 int whence;
88 /**
89 * If set to 0, don't perform any operations which would block the calling
90 * thread.
92 int block;
94 /**
95 * Status of the request.
97 int status;
98 /**
99 * Return value for the request type. Holds for example the number of bytes
100 * read/written, or -1 in case of an error.
102 int return_value;
104 * If set to 1, the request has been finished.
106 int finished;
109 * Calling process.
111 KeProcess *process;
114 * Thread waiting for the request to be completed. This will in many cases
115 * be 0, so don't rely on this being the thread which issued the request.
117 KeThread *caller;
120 * Request lock. Can be used by file systems.
122 KeSpinlock lock;
123 } FsRequest;
126 * Creates a file system request.
127 * \param request Request to be issued.
128 * \param wait If set to 1, blocks until the request has been completed.
129 * \param process Used to override the process member of the request. If it is
130 * 0, the process is retrieved automatically.
132 int fsCreateRequest(FsRequest *request, int wait, KeProcess *process);
134 * Waits for a request to be completed.
136 int fsWaitRequest(FsRequest *request);
139 * Finishes a request and wakes up any thread waiting for it.
141 int fsFinishRequest(FsRequest *request);
143 #endif