fseek endup with ERROR "Function not implemented" (ENOSYS)

117 Views Asked by At

I've function that opens up a file and than setting it pos from nvs at the program start-up. Everything happens after short time and function call end up with error that says [Line : 670] fseek ERROR : Function not implemented. After short period of time another call works.

I wonder what may cause the problem becouse before I use this specific example with fseek I do multiple fopen/fclose on different files.

        FILE *file;
        file = fopen("/spiffs/data/log.log", "rb+");
        if(file == NULL) return;
        if(fseek(file, 30, SEEK_SET) != 0) {
            fprintf(stderr, "[Line : %d] fseek ERROR : ", __LINE__);
            perror("");
        }

File itself is full of data and it length is 10kB

@edit after what @Andrew Henle said in the comment I have looked into what fseek can actualy return. I find out under this link that fseek has no ENOSYS as return. Which means his point is right but Iam making lots of fopen/fclose/fread before this function call. What conditions has to occur for this error to be returned by f* functions?

1

There are 1 best solutions below

2
Filipe On

Is it possible for you to post the file in question?

What i can understand is that the file is being opened and the fseek is doing its job

https://www.tutorialspoint.com/c_standard_library/c_function_fseek.htm

Try to see what value the fseek gets and if the file ends before 30.

You could use fgets(), but i'm pretty sure fseek is the best method to what your doing.