Skip to content

Commit 5d440e6

Browse files
committed
Added support of GetStreamRedirections
1 parent 82408ec commit 5d440e6

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

inc/dmod_sal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ DMOD_BUILTIN_API(Dmod, 1.0, int, _GetProcessResult, ( Dmod_Pid_t Pid ) );
454454
DMOD_BUILTIN_API(Dmod, 1.0, Dmod_Pid_t, _GetCurrentPid, (void));
455455
DMOD_BUILTIN_API(Dmod, 1.0, void*, _ResolveStreamFile, ( Dmod_Pid_t Pid, void* StdHandle ) );
456456
DMOD_BUILTIN_API(Dmod, 1.0, int, _SetStreamFilePath, ( Dmod_Pid_t Pid, void* StdHandle, const char* Path ) );
457+
DMOD_BUILTIN_API(Dmod, 1.0, int, _GetStreamRedirections, ( Dmod_Pid_t Pid, Dmod_StreamRedirection_t* OutEntries, size_t MaxEntries, size_t* OutCount ) );
458+
457459
DMOD_BUILTIN_API(Dmod, 1.0, void*, _LockStdio, ( void* StdHandle ));
458460
DMOD_BUILTIN_API(Dmod, 1.0, void, _UnlockStdio, ( void* StdHandle ));
459461

src/system/if/dmod_if_proc.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,14 @@ DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, void*, _ResolveStreamFile, ( Dmod_Pid
209209
/**
210210
* @brief Register the path of the file backing one of a process's standard streams
211211
*
212-
* This is a weak implementation that does nothing.
212+
* This is a weak implementation that does nothing. Path == NULL is meant to clear an
213+
* existing binding, but since this weak implementation never binds anything in the first
214+
* place, there is nothing to clear either.
213215
* The real implementation should be provided by the dmosi layer.
214216
*
215217
* @param Pid Process ID to set the stream file path for
216218
* @param StdHandle One of DMOD_STDIN/DMOD_STDOUT/DMOD_STDERR/DMOD_STDLOG
217-
* @param Path Path of the file to associate with this (Pid, StdHandle) pair
219+
* @param Path Path of the file to associate with this (Pid, StdHandle) pair, or NULL to clear it
218220
*/
219221
DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, int, _SetStreamFilePath, ( Dmod_Pid_t Pid, void* StdHandle, const char* Path ))
220222
{
@@ -224,6 +226,31 @@ DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, int, _SetStreamFilePath, ( Dmod_Pid_t
224226
return -ENOSYS;
225227
}
226228

229+
/**
230+
* @brief Snapshot the currently explicitly-bound standard streams of a process
231+
*
232+
* This is a weak implementation that always reports an empty snapshot (nothing bound),
233+
* since this weak implementation never binds anything via Dmod_SetStreamFilePath either.
234+
* The real implementation should be provided by the dmosi layer.
235+
*
236+
* @param Pid Process ID to snapshot
237+
* @param OutEntries Buffer to receive the snapshot entries
238+
* @param MaxEntries Capacity of OutEntries, in entries
239+
* @param OutCount Receives the number of entries written to OutEntries (always 0 here)
240+
* @return 0
241+
*/
242+
DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, int, _GetStreamRedirections, ( Dmod_Pid_t Pid, Dmod_StreamRedirection_t* OutEntries, size_t MaxEntries, size_t* OutCount ))
243+
{
244+
(void)Pid;
245+
(void)OutEntries;
246+
(void)MaxEntries;
247+
if( OutCount != NULL )
248+
{
249+
*OutCount = 0;
250+
}
251+
return 0;
252+
}
253+
227254
/**
228255
* @brief Locks the stdio buffer (for current pid) to protect against recursive calls
229256
*

0 commit comments

Comments
 (0)