udev-watch.c revision b26fa1a2fbcfee7d03b0c8fd15ec3aa64ae70b9f
/*
* Copyright (C) 2004-2012 Kay Sievers <kay@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 <dirent.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include "stdio-util.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;
log_error_errno(errno, "unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
return;
}
char device[UTIL_PATH_SIZE];
struct udev_device *dev;
continue;
goto unlink;
goto unlink;
}
log_error_errno(errno, "unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
}
char filename[UTIL_PATH_SIZE];
int wd;
int r;
if (inotify_fd < 0)
return;
if (wd < 0) {
return;
}
if (r < 0)
}
int wd;
char filename[UTIL_PATH_SIZE];
if (inotify_fd < 0)
return;
if (wd < 0)
return;
}
char filename[UTIL_PATH_SIZE];
char device[UTIL_NAME_SIZE];
if (inotify_fd < 0 || wd < 0)
return NULL;
return NULL;
}