5HT / fs

📁 FS: Windows, Linux, Mac Driver
https://fs.n2o.dev
Other
235 stars 69 forks source link

Doesn't work on BSD #21

Open amiramix opened 8 years ago

amiramix commented 8 years ago

Trying to start n2o:

g@crayon2:~/work/n2o/samples % ./mad repl
Configuration: [{n2o,[{port,8000},
                      {app,review},
                      {upload,"./apps/review/priv/static/"},
                      {search,"/Users/5HT/depot/synrc/synrc.com/apps/*/doc/web/*.htm"},
                      {route,routes},
                      {mq,n2o_mq},
                      {formatter,bert},
                      {log_modules,config},
                      {log_level,config},
                      {log_backend,n2o_log},
                      {session,n2o_session},
                      {origin,<<"*">>},
                      {bridge,n2o_cowboy},
                      {pickler,n2o_pickle},
                      {erroring,n2o_error},
                      {event,pickle}]},
                {kvs,[{dba,store_mnesia},
                      {schema,[kvs_user,kvs_acl,kvs_feed,kvs_subscription]}]}]
Applications: [kernel,stdlib,fs,ranch,crypto,compiler,syntax_tools,mnesia,
               inets,gproc,kvs,cowlib,cowboy,n2o,review,active,erlydtl,jsone,
               mad,nitro,rest,sh]
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.2.1  (abort with ^G)
1> 
=INFO REPORT==== 19-Mar-2016::12:51:11 ===
    application: fs
    exited: {{shutdown,
                 {failed_to_start_child,fs_server,
                     {badarg,
                         [{erlang,open_port,
                              [{spawn_executable,"deps/fs/priv/kqueue"},
                               [stream,exit_status,
                                {line,16384},
                                {args,"/usr/home/g/work/n2o/samples"},
                                {cd,"/usr/home/g/work/n2o/samples"}]],
                              []},
                          {kqueue,start_port,2,
                              [{file,
                                   "/usr/home/g/work/n2o/samples/deps/fs/src/sys/kqueue.erl"},
                               {line,11}]},
                          {fs_server,init,1,
                              [{file,
                                   "/usr/home/g/work/n2o/samples/deps/fs/src/fs_server.erl"},
                               {line,11}]},
                          {gen_server,init_it,6,
                              [{file,"gen_server.erl"},{line,328}]},
                          {proc_lib,init_p_do_apply,3,
                              [{file,"proc_lib.erl"},{line,240}]}]}}},
             {fs_app,start,[normal,[]]}}
    type: temporary
Nonexistent: []

               Apps couldn't be loaded: [fs]

I modified c_src/bsd/main.c to return different error codes:

   if ((fd = open(argv[1], O_RDONLY)) == -1) return 1;
    EV_SET(&change, fd, EVFILT_VNODE , EV_ADD
                                     | EV_ENABLE
                                     | EV_DISABLE
                                     | EV_CLEAR
                                     | EV_DELETE
                                     | EV_EOF
                                     | EV_RECEIPT
                                     | EV_DISPATCH
                                     | EV_ONESHOT,
                                       NOTE_DELETE
                                     | NOTE_RENAME
                                     | NOTE_EXTEND
                                     | NOTE_ATTRIB
                                     | NOTE_LINK
                                     | NOTE_REVOKE
                                     | NOTE_WRITE, 0, 0);
    if ((kq = kqueue()) == -1) return 2;
    nev = kevent(kq, &change, 1, &event, 1, NULL);
    if (nev < 0) { return 3; } else if (nev > 0) { if (event.flags & EV_ERROR) { return 4; } }

Then:

g@crayon2:~/work/n2o/samples % ./deps/fs/priv/kqueue /usr/home/g/work/n2o/samples
g@crayon2:~/work/n2o/samples % echo $?
4

System is 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC

kuon commented 8 years ago

More info in https://github.com/synrc/fs/issues/17

mylanconnolly commented 7 years ago

I know it's been a while since the last comment, however I noticed that inotify-tools are in the Ports collection for FreeBSD.

I have installed the sysutils/inotify-tools port and it seems to function correctly. Is it possible to update to include support for FreeBSD? It shows up as {unix,freebsd} after running os:type().

If there's some other blocker (or it's unreliable on BSDs) I understand.

Thanks!