Thanks Bryan. Indeed in the zone /opt/local/bin/touch is used. But I still see the issue:
open(filename, O_WRONLY|O_NONBLOCK|O_CREAT|O_NOCTTY, 0666) is a file open operation and should result in no IN_CREATE event if the file exists (O_CREAT - Create the file if it does not exist). I used the following C program to test this file open behavior on Linux and SmartOS, as you can see, on SmartOS, it causes a IN_CREATE inotify event, while on Linux, it triggers nothing. This happens both in global zone and OS zone. I am confused. Thanks, --Youzhong ----------------------------------------------------------- #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int fd; char *filename; if(argc > 1) { filename = argv[1]; } else { printf("No filename specified!\n"); exit(1); } fd = open(filename, O_WRONLY|O_NONBLOCK|O_CREAT|O_NOCTTY, 0666); if(fd == -1) { perror("open"); exit(1); } close(fd); return 0; } On Wed, Dec 10, 2014 at 1:05 PM, Bryan Cantrill <bryancantr...@gmail.com> wrote: > > The touch differences can be explained by the touch(1) that you're using: > in the global zone, you're using /usr/bin/touch, but in the non-global, I > imagine that you're using /opt/local/bin/touch. These two implementations > differ, so not a huge surprise that their implementation details differ. > > As for FIONREAD: indeed, that seems screwed up -- it seems to be returning > the number of bytes instead of storing in in the specified argument. I'll > get that fixed today... > > - Bryan > > > > On Wed, Dec 10, 2014 at 8:00 AM, Youzhong Yang via smartos-discuss < > smartos-discuss@lists.smartos.org> wrote: > >> Hello again, >> >> I downloaded smartos latest image (joyent_20141127T173954Z) and tested >> inotify using it. >> >> Two issues were observed: >> >> 1. ioctl(fd, FIONREAD, ...) does not work as expected. It does not return >> the number of bytes that are available to be read on an inotify instance. >> >> 2. In an OS zone, touching a file always generates an IN_CREATE event, >> even though the file already exists. This only happens in an OS zone, not >> in global zone. >> >> Attached is the test program I used for testing. Just compile and run it, >> then in another terminal window, 'touch /tmp/file' twice. Please look at >> the details at the end of this e-mail. >> >> Thanks, >> >> -Youzhong >> >> --- In global zone --- >> [root@batfs5999 /var/tmp]# ./inotify >> ioctl = 64, errno = 0, bufsize = 0 >> got 48 bytes >> :: mask 256 >> -> New file file created >> :: mask 4 >> -> file ATTRIB >> ioctl = 32, errno = 0, bufsize = 0 >> got 24 bytes >> :: mask 4 >> -> file ATTRIB >> >> --- In OS zone --- >> [root@batfs5999-cifs0 /var/tmp]# ./inotify >> ioctl = 64, errno = 0, bufsize = 0 >> got 48 bytes >> :: mask 256 >> -> New file file created >> :: mask 4 >> -> file ATTRIB >> ioctl = 64, errno = 0, bufsize = 0 >> got 48 bytes >> :: mask 256 >> -> New file file created >> :: mask 4 >> -> file ATTRIB >> >> --- On Linux --- >> % ./inotify >> ioctl = 0, errno = 0, bufsize = 32 >> got 32 bytes >> :: mask 256 >> -> New file file created >> ioctl = 0, errno = 0, bufsize = 32 >> got 32 bytes >> :: mask 4 >> -> file ATTRIB >> ioctl = 0, errno = 0, bufsize = 32 >> got 32 bytes >> :: mask 4 >> -> file ATTRIB >> >> *smartos-discuss* | Archives >> <https://www.listbox.com/member/archive/184463/=now> >> <https://www.listbox.com/member/archive/rss/184463/21493597-819305a5> | >> Modify >> <https://www.listbox.com/member/?&> >> Your Subscription <http://www.listbox.com> >> > > ------------------------------------------- smartos-discuss Archives: https://www.listbox.com/member/archive/184463/=now RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00 Modify Your Subscription: https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb Powered by Listbox: http://www.listbox.com