[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] kern_ioctl() should return ENOSYS



>I'm  pretty sure Ffstat64 is not implemented,

Im pretty sure it is (sys_ffstat in sys/dosfile.c). And even it it wasn't, its the same
as Fcntl(fd, &s, FSTAT64), which also fails with EINVAL.


>Could you post a stripped-down test-case using
> GEMDOS-calls (no 
> mintlib+stuff)?

Tried this:

#include <stdio.h>
#include <mintbind.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>

#ifndef FSTAT64
#define FSTAT64           (('F'<< 8) | 6)
#endif

static char const TESTFILE[] = "/kern/hz";

int main(void)
{
	long fd;
	long ret;
	struct stat s;
	char buf[100];
	
	fd = Fopen(TESTFILE, O_RDONLY);
	if (fd < 0)
	{
		fprintf(stderr, "Fopen(%s) failed: %ld\n", TESTFILE, fd);
		return 1;
	}
	
	ret = Ffstat64((short)fd, &s);
	if (ret < 0)
	{
		fprintf(stderr, "Fstat64(%ld) failed: %ld\n", fd, ret);
	}
	
	ret = Fcntl((short)fd, &s, FSTAT64);
	if (ret < 0)
	{
		fprintf(stderr, "Fcntl(%ld) failed: %ld\n", fd, ret);
	}
	
	ret = Fread((short)fd, sizeof(buf) - 1, buf);
	if (ret < 0)
	{
		fprintf(stderr, "Fread(%ld) failed: %ld\n", fd, ret);
	} else
	{
		buf[ret] = 0;
		printf("result: %s\n", buf);
	}
	
	Fclose((short)fd);
	
	return 0;
}


With the current kernel, it prints the 2 error messages for Ffstat64() and Fcntl(). When i change kern_ioctl() to return ENOSYS instead, the 2 errors disappear. The Fread() succeeds in both cases.

So sorry about complaining about cat ( i can only guess that the "official" version was also cross-compiled, using the original configure script, which falls back using a replaced stat() from the gnulib modules). But the behviour of the kernel calls is still wrong IMHO. If you look at other sources (like pipefs,c shmfs.c etc) you will also see that they all return ENOSYS in case of unhandled mode arguments. Its only kernfs.c that returns EINVAL.