server: Fixed compile without inotify.
This commit is contained in:
parent
0c27db0d24
commit
cf9ced5e69
|
@ -122,25 +122,7 @@ static inline int inotify_remove_watch( int fd, int wd )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#define USE_INOTIFY
|
||||||
|
|
||||||
static inline int inotify_init( void )
|
|
||||||
{
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int inotify_add_watch( int fd, const char *name, unsigned int mask )
|
|
||||||
{
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int inotify_remove_watch( int fd, int wd )
|
|
||||||
{
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -348,11 +330,7 @@ static void dir_destroy( struct object *obj )
|
||||||
remove_change( dir );
|
remove_change( dir );
|
||||||
|
|
||||||
if (dir->inotify_fd)
|
if (dir->inotify_fd)
|
||||||
{
|
|
||||||
if (dir->wd != -1)
|
|
||||||
inotify_remove_watch( get_unix_fd( dir->inotify_fd ), dir->wd );
|
|
||||||
release_object( dir->inotify_fd );
|
release_object( dir->inotify_fd );
|
||||||
}
|
|
||||||
|
|
||||||
if (dir->event)
|
if (dir->event)
|
||||||
{
|
{
|
||||||
|
@ -379,6 +357,8 @@ static int dir_get_info( struct fd *fd )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_INOTIFY
|
||||||
|
|
||||||
static int inotify_get_poll_events( struct fd *fd );
|
static int inotify_get_poll_events( struct fd *fd );
|
||||||
static void inotify_poll_event( struct fd *fd, int event );
|
static void inotify_poll_event( struct fd *fd, int event );
|
||||||
static int inotify_get_info( struct fd *fd );
|
static int inotify_get_info( struct fd *fd );
|
||||||
|
@ -434,12 +414,27 @@ static int inotify_get_info( struct fd *fd )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inotify_adjust_changes( struct dir *dir )
|
static inline struct fd *create_inotify_fd( struct dir *dir )
|
||||||
{
|
{
|
||||||
int filter = dir->filter;
|
int unix_fd;
|
||||||
|
|
||||||
|
unix_fd = inotify_init();
|
||||||
|
if (unix_fd<0)
|
||||||
|
return NULL;
|
||||||
|
return create_anonymous_fd( &inotify_fd_ops, unix_fd, &dir->obj );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int inotify_adjust_changes( struct dir *dir )
|
||||||
|
{
|
||||||
|
unsigned int filter = dir->filter;
|
||||||
unsigned int mask = 0;
|
unsigned int mask = 0;
|
||||||
char link[32];
|
char link[32];
|
||||||
|
|
||||||
|
if (!dir->inotify_fd)
|
||||||
|
{
|
||||||
|
if (!(dir->inotify_fd = create_inotify_fd( dir ))) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (filter & FILE_NOTIFY_CHANGE_FILE_NAME)
|
if (filter & FILE_NOTIFY_CHANGE_FILE_NAME)
|
||||||
mask |= (IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE | IN_CREATE);
|
mask |= (IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE | IN_CREATE);
|
||||||
if (filter & FILE_NOTIFY_CHANGE_DIR_NAME)
|
if (filter & FILE_NOTIFY_CHANGE_DIR_NAME)
|
||||||
|
@ -461,17 +456,10 @@ static void inotify_adjust_changes( struct dir *dir )
|
||||||
dir->wd = inotify_add_watch( get_unix_fd( dir->inotify_fd ), link, mask );
|
dir->wd = inotify_add_watch( get_unix_fd( dir->inotify_fd ), link, mask );
|
||||||
if (dir->wd != -1)
|
if (dir->wd != -1)
|
||||||
set_fd_events( dir->inotify_fd, POLLIN );
|
set_fd_events( dir->inotify_fd, POLLIN );
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct fd *create_inotify_fd( struct dir *dir )
|
#endif /* USE_INOTIFY */
|
||||||
{
|
|
||||||
int unix_fd;
|
|
||||||
|
|
||||||
unix_fd = inotify_init();
|
|
||||||
if (unix_fd<0)
|
|
||||||
return NULL;
|
|
||||||
return create_anonymous_fd( &inotify_fd_ops, unix_fd, &dir->obj );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* enable change notifications for a directory */
|
/* enable change notifications for a directory */
|
||||||
DECL_HANDLER(read_directory_changes)
|
DECL_HANDLER(read_directory_changes)
|
||||||
|
@ -512,13 +500,10 @@ DECL_HANDLER(read_directory_changes)
|
||||||
if (dir->signaled>0)
|
if (dir->signaled>0)
|
||||||
dir->signaled--;
|
dir->signaled--;
|
||||||
|
|
||||||
if (!dir->inotify_fd)
|
|
||||||
dir->inotify_fd = create_inotify_fd( dir );
|
|
||||||
|
|
||||||
/* setup the real notification */
|
/* setup the real notification */
|
||||||
if (dir->inotify_fd)
|
#ifdef USE_INOTIFY
|
||||||
inotify_adjust_changes( dir );
|
if (!inotify_adjust_changes( dir ))
|
||||||
else
|
#endif
|
||||||
dnotify_adjust_changes( dir );
|
dnotify_adjust_changes( dir );
|
||||||
|
|
||||||
set_error(STATUS_PENDING);
|
set_error(STATUS_PENDING);
|
||||||
|
|
Loading…
Reference in New Issue