devman: isseekable()

This commit is contained in:
Matheus
2022-09-24 14:54:26 -03:00
parent ad768d0392
commit 1599890ce9
6 changed files with 38 additions and 6 deletions
+3
View File
@@ -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
+10
View File
@@ -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();
+6 -1
View File
@@ -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(){
+6 -1
View File
@@ -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(){
+6 -1
View File
@@ -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(){
+7 -3
View File
@@ -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(){