Coverage report for bus/dir-watch.c.gcov

        -:    0:Source:dir-watch.c
        -:    0:Graph:dir-watch.gcno
        -:    0:Data:dir-watch.gcda
        -:    0:Runs:10118
        -:    0:Programs:2
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* dir-watch.c  OS specific directory change notification for message bus
        -:    3: *
        -:    4: * Copyright (C) 2003 Red Hat, Inc.
        -:    5: *
        -:    6: * Licensed under the Academic Free License version 2.1
        -:    7: * 
        -:    8: * This program is free software; you can redistribute it and/or modify
        -:    9: * it under the terms of the GNU General Public License as published by
        -:   10: * the Free Software Foundation; either version 2 of the License, or
        -:   11: * (at your option) any later version.
        -:   12: *
        -:   13: * This program is distributed in the hope that it will be useful,
        -:   14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   16: * GNU General Public License for more details.
        -:   17: * 
        -:   18: * You should have received a copy of the GNU General Public License
        -:   19: * along with this program; if not, write to the Free Software
        -:   20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        -:   21: *
        -:   22: */
        -:   23:
        -:   24:#include <config.h>
        -:   25:
        -:   26:#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 
        -:   27:#define _GNU_SOURCE
        -:   28:#include <stdlib.h>
        -:   29:#include <unistd.h>
        -:   30:#include <fcntl.h>
        -:   31:#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */
        -:   32:
        -:   33:#include <dbus/dbus-internals.h>
        -:   34:#include "dir-watch.h"
        -:   35:
        -:   36:
        -:   37:/* D_NOTIFY is available on Linux 2.4 or greater - the actual SIGIO signal is handled in main.c:signal_handler() */
        -:   38:#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 
        -:   39:
        -:   40:#define MAX_DIRS_TO_WATCH 128
        -:   41:
        -:   42:/* use a static array to avoid handling OOM */
        -:   43:static int fds[MAX_DIRS_TO_WATCH];
        -:   44:static int num_fds = 0;
        -:   45:
        -:   46:void
        -:   47:bus_watch_directory (const char *dir, void *userdata)
function bus_watch_directory called 0 returned 0% blocks executed 0%
    #####:   48:{
        -:   49:  int fd;
        -:   50:
    #####:   51:  _dbus_assert (dir != NULL);
call    0 never executed
        -:   52:
    #####:   53:  if (num_fds >= MAX_DIRS_TO_WATCH )
branch  0 never executed
branch  1 never executed
        -:   54:    {
    #####:   55:      _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH);
call    0 never executed
    #####:   56:      goto out;
        -:   57:    }
        -:   58:
    #####:   59:  fd = open (dir, O_RDONLY);
call    0 never executed
    #####:   60:  if (fd < 0)
branch  0 never executed
branch  1 never executed
        -:   61:    {
    #####:   62:      _dbus_warn ("Cannot open directory '%s'; error '%s'\n", dir, _dbus_strerror (errno));
call    0 never executed
call    1 never executed
call    2 never executed
    #####:   63:      goto out;
        -:   64:    }
        -:   65:
    #####:   66:  if (fcntl (fd, F_NOTIFY, DN_DELETE|DN_RENAME|DN_MODIFY) == -1)
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:   67:    {
    #####:   68:      _dbus_warn ("Cannot setup D_NOTIFY for '%s' error '%s'\n", dir, _dbus_strerror (errno));
call    0 never executed
call    1 never executed
call    2 never executed
    #####:   69:      close (fd);
call    0 never executed
    #####:   70:      goto out;
        -:   71:    }
        -:   72:  
    #####:   73:  fds[num_fds++] = fd;
    #####:   74:  _dbus_verbose ("Added watch on config directory '%s'\n", dir);
call    0 never executed
        -:   75:
    #####:   76: out:
        -:   77:  ;
    #####:   78:}
        -:   79:
        -:   80:void 
        -:   81:bus_drop_all_directory_watches (void)
function bus_drop_all_directory_watches called 0 returned 0% blocks executed 0%
    #####:   82:{
    #####:   83:  _dbus_verbose ("Dropping all watches on config directories\n");
call    0 never executed
        -:   84:
        -:   85:  int i;
        -:   86:  
    #####:   87:  for (i = 0; i < num_fds; i++)
branch  0 never executed
branch  1 never executed
        -:   88:    {
    #####:   89:      if (close (fds[i]) != 0)
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:   90:	{
    #####:   91:	  _dbus_verbose ("Error closing fd %d for config directory watch\n", fds[i]);
call    0 never executed
        -:   92:	}
        -:   93:    }
        -:   94:  
    #####:   95:  num_fds = 0;
    #####:   96:}
        -:   97:
        -:   98:#else /* fallback to NOP */
        -:   99:
        -:  100:void 
        -:  101:bus_drop_all_directory_watches (void)
        -:  102:{
        -:  103:}
        -:  104:
        -:  105:void
        -:  106:bus_watch_directory (const char *dir, void *userdata)
        -:  107:{
        -:  108:}
        -:  109:
        -:  110:#endif