lseek() on dir handle does not work as expected (#1224)
* Document lseek on dir will not work as expected
This commit is contained in:
Родитель
d37cee6fab
Коммит
49154dd62f
|
@ -179,6 +179,7 @@ If your use-case involves updating/uploading file(s) through other means and you
|
|||
- chown : Change of ownership is not supported by Azure Storage hence Blobfuse2 does not support this.
|
||||
- Creation of device files or pipes is not supported by Blobfuse2.
|
||||
- Blobfuse2 does not support extended-attributes (x-attrs) operations
|
||||
- Blobfuse2 does not support lseek() operation on directory handles. No error is thrown but it will not work as expected.
|
||||
|
||||
## Un-Supported Scenarios
|
||||
- Blobfuse2 does not support overlapping mount paths. While running multiple instances of Blobfuse2 make sure each instance has a unique and non-overlapping mount point.
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#define handle_error(msg) \
|
||||
do { perror(msg); exit(EXIT_FAILURE); } while (0)
|
||||
|
||||
// To compile this file use "gcc dir_list_seek.c -o dir_list_seek"
|
||||
// To run this util use "./dir_list_seek <path to mounted directory"
|
||||
|
||||
struct linux_dirent {
|
||||
long d_ino;
|
||||
off_t d_off;
|
||||
unsigned short d_reclen;
|
||||
char d_name[];
|
||||
};
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd, nread;
|
||||
char buf[BUF_SIZE];
|
||||
struct linux_dirent *d;
|
||||
int bpos;
|
||||
char d_type;
|
||||
|
||||
fd = open(argc > 1 ? argv[1] : ".", O_RDONLY | O_DIRECTORY);
|
||||
if(fd == -1)
|
||||
handle_error("open");
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
nread = syscall(SYS_getdents, fd, buf, BUF_SIZE);
|
||||
if(nread == -1)
|
||||
handle_error("getdents");
|
||||
|
||||
if(nread == 0)
|
||||
break;
|
||||
|
||||
printf("--------------- nread=%d ---------------\n", nread);
|
||||
printf("i-node# file type d_reclen d_off d_name\n");
|
||||
|
||||
for(bpos=0; bpos<nread; ) {
|
||||
d = (struct linux_dirent *)(buf+bpos);
|
||||
printf("%8ld ", d->d_ino);
|
||||
d_type = *(buf + bpos + d->d_reclen - 1);
|
||||
printf("%-10s ", (d_type == DT_REG) ? "regular" :
|
||||
(d_type == DT_DIR) ? "directory" :
|
||||
(d_type == DT_FIFO) ? "FIFO" :
|
||||
(d_type == DT_SOCK) ? "socket" :
|
||||
(d_type == DT_LNK) ? "symlink" :
|
||||
(d_type == DT_BLK) ? "block dev" :
|
||||
(d_type == DT_CHR) ? "char dev" : "???");
|
||||
printf("%4d %10lld %s\n", d->d_reclen,
|
||||
(long long) d->d_off, d->d_name);
|
||||
bpos += d->d_reclen;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Загрузка…
Ссылка в новой задаче