Web lists-archives.com

Re: [Samba] Does samba support fsync() a directory?




Hi, Jeremy:

>  Can you show us the wireshark trace and the smbd logs
Sorry that I don't known how to use wireshark now.

I have the ptrace log:
```
execve("/home/fujitsu/a.out", ["/home/fujitsu/a.out"], [/* 22 vars */]) = 0
brk(0)                                  = 0x8ce000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f27a257d000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=73077, ...}) = 0
mmap(NULL, 73077, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f27a256b000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2116736, ...}) = 0
mmap(NULL, 3932672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f27a1f9e000
mprotect(0x7f27a2154000, 2097152, PROT_NONE) = 0
mmap(0x7f27a2354000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f27a2354000 mmap(0x7f27a235a000, 16896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f27a235a000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f27a256a000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f27a2568000
arch_prctl(ARCH_SET_FS, 0x7f27a2568740) = 0
mprotect(0x7f27a2354000, 16384, PROT_READ) = 0
mprotect(0x600000, 4096, PROT_READ)     = 0
mprotect(0x7f27a257e000, 4096, PROT_READ) = 0
munmap(0x7f27a256b000, 73077)           = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f27a257c000
write(1, "open aaa\n", 9open aaa
)               = 9
open("aaa", O_RDONLY|O_DIRECTORY)       = 3
write(1, "sync aaa\n", 9sync aaa
)               = 9
fsync(3)                                = -1 EINVAL (Invalid argument)
dup(2)                                  = 4
fcntl(4, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
brk(0)                                  = 0x8ce000
brk(0x8ef000)                           = 0x8ef000
brk(0)                                  = 0x8ef000
fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f27a257b000
write(4, "sync aaa: Invalid argument\n", 27sync aaa: Invalid argument
) = 27
close(4)                                = 0
munmap(0x7f27a257b000, 4096)            = 0
write(1, "OK\n", 3OK
)                     = 3
exit_group(0)                           = ?
+++ exited with 0 +++
```

Best Regards
Cao

在 2018年02月02日 20:54, Jeremy Allison 写道:
On Fri, Feb 02, 2018 at 08:34:29PM +0800, 曹树烽 via samba wrote:
Hi group:
     I need some help!
     I use samba 4.5.8
     And I mount a samba directory from CentOS 7.

     When I run such program in the mounted directory:
```

#include  <stdlib.h>
#include  <stdio.h>
#include  <errno.h>
#include  <fcntl.h>
#include  <string.h>
int  main()  {
	printf("open aaa\n");
  	int  fd  =  open("aaa",  O_RDONLY  |  O_DIRECTORY,  0);
  	if  (fd  <  0)  {
  	perror("open aaa");
   	}
   	printf("sync aaa\n");
   	if(fsync(fd))  {
   	perror("sync aaa");
   	}
   	printf("OK\n");
   	return  0;
}

```
	I get such error: `sync aaa: Invalid argument`
	Is this expected for samba?
	Thanks in advance!
Can you show us the wireshark trace and the smbd logs
from this please ?







--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba