diff --git a/src/include/kernel/devman.h b/src/include/kernel/devman.h index 926580a1..68bab37b 100644 --- a/src/include/kernel/devman.h +++ b/src/include/kernel/devman.h @@ -7,17 +7,20 @@ #define MAJOR_ZERO 2 #define MAJOR_NULL 3 #define MAJOR_FULL 4 +#define MAJOR_FB 5 typedef struct{ int (*read)(int* error, int minor, void* buff, size_t count, size_t offset); int (*write)(int* error, int minor, void* buff, size_t count, size_t offset); int (*isatty)(int minor); + int (*isseekable)(int minor, size_t* seekmax); } devcalls; int devman_read(int *error, int dev, void* buff, size_t count, size_t offset); int devman_write(int *error, int dev, void* buff, size_t count, size_t offset); int devman_newdevice(char* name, int type, int major, int minor, devcalls* calls); int devman_isatty(int dev); +int devman_isseekable(int dev, size_t* seekmax); void devman_init(); #endif diff --git a/src/sys/devman.c b/src/sys/devman.c index 4f35a889..b6908566 100644 --- a/src/sys/devman.c +++ b/src/sys/devman.c @@ -56,6 +56,16 @@ int devman_isatty(int dev){ } +int devman_isseekable(int dev, size_t* max){ + + if(major(dev) > highestmajor) + return ENOTTY; + + return majorcalls[major(dev)]->isseekable(minor(dev), max); + +} + + void devman_init(){ devfs_init(); diff --git a/src/sys/pseudodevs/full.c b/src/sys/pseudodevs/full.c index 9f885989..d9b25457 100644 --- a/src/sys/pseudodevs/full.c +++ b/src/sys/pseudodevs/full.c @@ -17,8 +17,13 @@ static int isatty(int minor){ return ENOTTY; } +static int isseekable(int minor, size_t* max){ + *max = ~(size_t)0; + return 0; +} + static devcalls calls = { - read, write, isatty + read, write, isatty, isseekable }; void fulldev_init(){ diff --git a/src/sys/pseudodevs/null.c b/src/sys/pseudodevs/null.c index 6eca12b5..ecdac6ef 100644 --- a/src/sys/pseudodevs/null.c +++ b/src/sys/pseudodevs/null.c @@ -16,8 +16,13 @@ static int isatty(int minor){ return ENOTTY; } +static int isseekable(int minor, size_t* max){ + *max = ~(size_t)0; + return 0; +} + static devcalls calls = { - read, write, isatty + read, write, isatty, isseekable }; void nulldev_init(){ diff --git a/src/sys/pseudodevs/zero.c b/src/sys/pseudodevs/zero.c index d93e7e8b..a842004b 100644 --- a/src/sys/pseudodevs/zero.c +++ b/src/sys/pseudodevs/zero.c @@ -17,8 +17,13 @@ static int isatty(int minor){ return ENOTTY; } +static int isseekable(int minor, size_t* max){ + *max = ~(size_t)0; + return 0; +} + static devcalls calls = { - read, write, isatty + read, write, isatty, isseekable }; void zerodev_init(){ diff --git a/src/video/consoledev.c b/src/video/consoledev.c index 6dc052c2..a38125b9 100644 --- a/src/video/consoledev.c +++ b/src/video/consoledev.c @@ -120,10 +120,14 @@ static int write(int *error, int dev, void* buff, size_t count, size_t offset){ return count; } -devcalls calls = { - read, write, isatty -}; +static int isseekable(){ + return ESPIPE; +} + +devcalls calls = { + read, write, isatty, isseekable +}; void consoledev_init(){