[Mono-devel-list] PosixStream

Jonathan Pryor jonpryor at vt.edu
Mon Sep 20 06:19:46 EDT 2004


I cooked up an PosixStream implementation on Saturday.  It's incomplete:
for simplicity reasons, the current implementation stands alone from
Mono.Posix.  On the bright side, this means anyone with Mono 1.0.1 can
compile & test this code.  The downside is it *really* needs to use the
Mono.Posix enumeration mapping mechanism for error number mapping; at
present, it uses the Linux error numbers, so this probably isn't
portable to non-Linux systems.  Another downside is that it's
incomplete: Syscall is missing fstat(2), fsync(2), ftruncate(2), so not
which impacts Length, Flush, and SetLength.

These issues will change once I migrate the code to be a patch against
Mono.Posix proper.

I do have some implementation questions, though:

Is it safe to assume that the convention that STDIN_FILENO=0,
STDOUT_FILENO=1, and STDERR_FILENO=2 be a universal convention, or
should those values be mapped?

What about SEEK_SET, SEEK_CUR, SEEK_END?

How do I tell if O_ASYNC has been set on the file descriptor?  It would
be nice to automatically detect this and then implement the Begin*
methods in terms of POSIX asynchronous I/O.

What about 64-bit support?  I'm currently using the non-64 APIs
(fstat(2) instead of fstat64, etc), which limits file sizes to 2GB. 
This is non-desirable, I'm sure.  Should Mono.Posix export the 64-bit
APIs as well, or should we increase the work of libMonoPosixHelper so
that it exports the "flexible" POSIX APIs, so that we can have a
configure check for the extended functions and use them if possible,
e.g.

	extern int Mono_Posix_truncate (uint32_t fd, uint64_t length)
	{
	#if HAVE_FTRUNCATE64
		return ftruncate64 (fd, length);
	#else
		if (length > MAX_INT) return EINVAL;
		return trucate (fd, (off_t) length);
	#endif
	}

This would simplify (slightly) Mono.Posix, as it wouldn't need to worry
about the *64 functions, but it would increase the work of
libMonoPosixHelper.

Thanks,

 - Jon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PosixStream.cs
Type: text/x-csharp
Size: 14507 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040920/cf066ead/attachment.bin 


More information about the Mono-devel-list mailing list