udev-watch.c revision 4ec9c3e79771aa95586390cecff4218cc8938160
/*
* Copyright (C) 2004-2010 Kay Sievers <kay.sievers@vrfy.org>
* Copyright (C) 2009 Canonical Ltd.
* Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <dirent.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "udev.h"
static int inotify_fd = -1;
/* inotify descriptor, will be shared with rules directory;
* set to cloexec since we need our children to be able to add
* watches for us
*/
{
if (inotify_fd < 0)
return inotify_fd;
}
/* move any old watches directory out of the way, and then restore
* the watches
*/
{
if (inotify_fd < 0)
return;
return;
}
char device[UTIL_PATH_SIZE];
char *s;
size_t l;
struct udev_device *dev;
continue;
s = device;
goto unlink;
s[len] = '\0';
goto unlink;
}
}
}
{
char filename[UTIL_PATH_SIZE];
int wd;
if (inotify_fd < 0)
return;
if (wd < 0) {
return;
}
}
{
int wd;
char filename[UTIL_PATH_SIZE];
if (inotify_fd < 0)
return;
if (wd < 0)
return;
}
{
char filename[UTIL_PATH_SIZE];
char majmin[UTIL_PATH_SIZE];
char *s;
size_t l;
if (inotify_fd < 0 || wd < 0)
return NULL;
s = majmin;
return NULL;
s[len] = '\0';
return udev_device_new_from_id_filename(udev, s);
}