arun
arun

Reputation: 41

readdir API trying to read a file greater than 2 GB

I am new to Linux API Programming . I am trying to implement a error scenario where 32 bit readdir() API is trying to read a file greater than 2 GB .

Here is the scenario

  1. Invoke 32 bit readdir API on a large file which is greater than 2 GB.

What is the error message thrown when 32 bit readdir API tries to read a file which is greater than 2 GB. Is it EOVERFLOW ?

What is the dirent return value of readdir ? Is it NULL ??

int i;
FILE *fp;
DIR *dir;
struct dirent *dirp;
int errno;

dir=opendir("/home/tmp-dir"); ==> which has large files greater than 2GB 
for(i=1;i<=15;i++)
{
    errno = 0;
    dirp=readdir(dir);
    printf(" File name = %s   Error Number = %s \n", dirp->d_name, 
          strerror(errno) );

    if (errno!= EOVERFLOW )
    {
        printf("**readdir:  readdir() set errno to %d (%s)  Expected 
        EOVERFLOW  (%d) \n", errno, strerror(errno), 
        EOVERFLOW );

    }

}

closedir(dir);
return (0);
}

I am thinking that 32 bit readdir API will display EOVERFLOW when it is trying to read a file greater than 2 GB. Please correct my understanding

Upvotes: 1

Views: 76

Answers (1)

melpomene
melpomene

Reputation: 85867

readdir doesn't read files. The premise of your question is false.

Upvotes: 1

Related Questions