diff -rupN udev-146.old/extras/cdrom_id/cdrom_id.c udev-146/extras/cdrom_id/cdrom_id.c --- udev-146.old/extras/cdrom_id/cdrom_id.c 2010-03-26 12:52:30.000000000 +0100 +++ udev-146/extras/cdrom_id/cdrom_id.c 2010-03-29 12:01:07.000000000 +0200 @@ -35,6 +35,10 @@ #include #include #include + +#ifdef __BIG_ENDIAN /*--- XXX BUSYBOX PATCH ---*/ +#undef __LITTLE_ENDIAN +#endif /*--- XXX BUSYBOX PATCH ---*/ #include #include "libudev.h" diff -rupN udev-146.old/extras/edd_id/edd_id.c udev-146/extras/edd_id/edd_id.c --- udev-146.old/extras/edd_id/edd_id.c 2010-03-26 12:52:30.000000000 +0100 +++ udev-146/extras/edd_id/edd_id.c 2010-03-26 13:00:05.000000000 +0100 @@ -22,10 +22,56 @@ #include #include #include +#include #include "libudev.h" #include "libudev-private.h" + + +/*--- #define HAVE_OPENAT ---*/ /*--- XXX BUSYBOX PATCH ---*/ + + + +#ifndef HAVE_OPENAT + +#define IS_ABSOLUTE_FILE_NAME(FNAME) ((FNAME)[0] == '/') +#ifndef AT_FDCWD +#define AT_FDCWD -100 +#endif + +/* Failing that, simulate it by doing save_cwd/fchdir/open/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as openat does. + Upon successful completion, return a file descriptor. */ +int openat (int fd, char const *file, int flags) +{ + char working_dir[PATH_MAX + 1]; + int err; + mode_t mode = 0; + + if(fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return open (file, flags, mode); + + if(!getcwd(working_dir, PATH_MAX)) + return -1; + + err = fchdir (fd); + if(!err) + return err; + + err = open (file, flags, mode); + if (chdir(working_dir) != 0) + return -1; + + return err; +} + +#endif /* #ifndef HAVE_OPENAT */ /*--- BUSYBOX PATCH XXX ---*/ + + + static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) diff -rupN udev-146.old/udev/udevadm-info.c udev-146/udev/udevadm-info.c --- udev-146.old/udev/udevadm-info.c 2010-03-26 12:52:30.000000000 +0100 +++ udev-146/udev/udevadm-info.c 2010-03-26 13:00:05.000000000 +0100 @@ -31,6 +31,61 @@ #include "udev.h" + +/*--- #define HAVE_FSTATAT ---*/ /*--- XXX BUSYBOX PATCH ---*/ + +#ifndef HAVE_FSTATAT + +#ifndef AT_FDCWD +#define AT_FDCWD -100 /* Special value used to indicate openat should use the current working directory. */ +#endif + +#ifndef AT_SYMLINK_NOFOLLOW +#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ +#endif + +#define IS_ABSOLUTE_FILE_NAME(FNAME) ((FNAME)[0] == '/') + +/* Simulate fstatat by doing save_cwd/fchdir/(stat|lstat)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as fstatat does. + Upon successful completion, return a file descriptor. */ +int fstatat(int fd, const char *path, struct stat *buf, int flags) +{ + char working_dir[PATH_MAX + 1]; + int err; + mode_t mode = 0; + + if(fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (path)) { + if(flags & AT_SYMLINK_NOFOLLOW) + return lstat(path, buf); + else + return stat(path, buf); + } + + if(!getcwd(working_dir, PATH_MAX)) + return -1; + + err = fchdir (fd); + if(!err) + return err; + + if(flags & AT_SYMLINK_NOFOLLOW) + err = lstat(path, buf); + else + err = stat(path, buf); + if (chdir(working_dir) != 0) + return -1; + + return err; +} + +#endif /* #ifndef HAVE_FSTATAT */ /*--- BUSYBOX PATCH XXX ---*/ + + + + static void print_all_attributes(struct udev_device *device, const char *key) { struct udev *udev = udev_device_get_udev(device); diff -rupN udev-146.old/udev/udev-watch.c udev-146/udev/udev-watch.c --- udev-146.old/udev/udev-watch.c 2010-03-26 12:52:30.000000000 +0100 +++ udev-146/udev/udev-watch.c 2010-03-26 13:00:05.000000000 +0100 @@ -30,6 +30,90 @@ #include "udev.h" + + +/*--- #define HAVE_LINKAT ---*/ /*--- XXX BUSYBOX PATCH ---*/ + +#ifndef HAVE_LINKAT + +#ifndef AT_FDCWD +#define AT_FDCWD -100 /* Special value used to indicate openat should use the current working directory. */ +#endif + +#ifndef AT_REMOVEDIR +#define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */ +#endif + +#define IS_ABSOLUTE_FILE_NAME(FNAME) ((FNAME)[0] == '/') + +/* Simulate unlinkat by doing save_cwd/fchdir/(unlink|rmdir)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as unlinkat does. + Upon successful completion, return a file descriptor. */ +int unlinkat (int fd, char const *file, int flags) +{ + char working_dir[PATH_MAX + 1]; + int err; + mode_t mode = 0; + + if(fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) { + if(flags & AT_REMOVEDIR) + return rmdir(file); + else + return unlink(file); + } + + if(!getcwd(working_dir, PATH_MAX)) + return -1; + + err = fchdir (fd); + if(!err) + return err; + + if(flags & AT_REMOVEDIR) + err = rmdir(file); + else + err = unlink(file); + if (chdir(working_dir) != 0) + return -1; + + return err; +} + +/* Simulate readlinkat by doing save_cwd/fchdir/readlink/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as readlinkat does. + Upon successful completion, return a file descriptor. */ +int readlinkat(int fd, const char *path, char *buf, size_t bufsize) +{ + char working_dir[PATH_MAX + 1]; + int err; + mode_t mode = 0; + + if(fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (path)) + return readlink(path, buf, bufsize); + + if(!getcwd(working_dir, PATH_MAX)) + return -1; + + err = fchdir (fd); + if(!err) + return err; + + err = readlink(path, buf, bufsize); + if (chdir(working_dir) != 0) + return -1; + + return err; +} + +#endif /* #ifndef HAVE_LINKAT */ /*--- BUSYBOX PATCH XXX ---*/ + + + + static int inotify_fd = -1; /* inotify descriptor, will be shared with rules directory;