hw/usb/dev-mtp: Guard inotify usage with CONFIG_INOTIFY1
inotify_init1 usage was guarded by a check for linux but does not exist on older distributions like CentOS 5 resulting in build failures. Signed-off-by: Matthew Fortune <matthew.fortune@imgtec.com> Message-id: 6D39441BF12EF246A7ABCE6654B023536BB85D4A@hhmail02.hh.imgtec.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f34d57d359
commit
983bff3530
@ -14,7 +14,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#include "qemu/main-loop.h"
|
#include "qemu/main-loop.h"
|
||||||
#endif
|
#endif
|
||||||
@ -92,7 +92,7 @@ enum {
|
|||||||
EP_EVENT,
|
EP_EVENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
typedef struct MTPMonEntry MTPMonEntry;
|
typedef struct MTPMonEntry MTPMonEntry;
|
||||||
|
|
||||||
struct MTPMonEntry {
|
struct MTPMonEntry {
|
||||||
@ -127,7 +127,7 @@ struct MTPObject {
|
|||||||
char *name;
|
char *name;
|
||||||
char *path;
|
char *path;
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
/* inotify watch cookie */
|
/* inotify watch cookie */
|
||||||
int watchfd;
|
int watchfd;
|
||||||
#endif
|
#endif
|
||||||
@ -152,7 +152,7 @@ struct MTPState {
|
|||||||
uint32_t next_handle;
|
uint32_t next_handle;
|
||||||
|
|
||||||
QTAILQ_HEAD(, MTPObject) objects;
|
QTAILQ_HEAD(, MTPObject) objects;
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
/* inotify descriptor */
|
/* inotify descriptor */
|
||||||
int inotifyfd;
|
int inotifyfd;
|
||||||
QTAILQ_HEAD(events, MTPMonEntry) events;
|
QTAILQ_HEAD(events, MTPMonEntry) events;
|
||||||
@ -400,7 +400,7 @@ static MTPObject *usb_mtp_add_child(MTPState *s, MTPObject *o,
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
static MTPObject *usb_mtp_object_lookup_name(MTPObject *parent,
|
static MTPObject *usb_mtp_object_lookup_name(MTPObject *parent,
|
||||||
char *name, int len)
|
char *name, int len)
|
||||||
{
|
{
|
||||||
@ -592,7 +592,7 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
|
|||||||
if (!dir) {
|
if (!dir) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
int watchfd = usb_mtp_add_watch(s->inotifyfd, o->path);
|
int watchfd = usb_mtp_add_watch(s->inotifyfd, o->path);
|
||||||
if (watchfd == -1) {
|
if (watchfd == -1) {
|
||||||
fprintf(stderr, "usb-mtp: failed to add watch for %s\n", o->path);
|
fprintf(stderr, "usb-mtp: failed to add watch for %s\n", o->path);
|
||||||
@ -996,7 +996,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
|
|||||||
trace_usb_mtp_op_open_session(s->dev.addr);
|
trace_usb_mtp_op_open_session(s->dev.addr);
|
||||||
s->session = c->argv[0];
|
s->session = c->argv[0];
|
||||||
usb_mtp_object_alloc(s, s->next_handle++, NULL, s->root);
|
usb_mtp_object_alloc(s, s->next_handle++, NULL, s->root);
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
if (usb_mtp_inotify_init(s)) {
|
if (usb_mtp_inotify_init(s)) {
|
||||||
fprintf(stderr, "usb-mtp: file monitoring init failed\n");
|
fprintf(stderr, "usb-mtp: file monitoring init failed\n");
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
|
|||||||
trace_usb_mtp_op_close_session(s->dev.addr);
|
trace_usb_mtp_op_close_session(s->dev.addr);
|
||||||
s->session = 0;
|
s->session = 0;
|
||||||
s->next_handle = 0;
|
s->next_handle = 0;
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
usb_mtp_inotify_cleanup(s);
|
usb_mtp_inotify_cleanup(s);
|
||||||
#endif
|
#endif
|
||||||
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
|
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
|
||||||
@ -1134,7 +1134,7 @@ static void usb_mtp_handle_reset(USBDevice *dev)
|
|||||||
|
|
||||||
trace_usb_mtp_reset(s->dev.addr);
|
trace_usb_mtp_reset(s->dev.addr);
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
usb_mtp_inotify_cleanup(s);
|
usb_mtp_inotify_cleanup(s);
|
||||||
#endif
|
#endif
|
||||||
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
|
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
|
||||||
@ -1297,7 +1297,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EP_EVENT:
|
case EP_EVENT:
|
||||||
#ifdef __linux__
|
#ifdef CONFIG_INOTIFY1
|
||||||
if (!QTAILQ_EMPTY(&s->events)) {
|
if (!QTAILQ_EMPTY(&s->events)) {
|
||||||
struct MTPMonEntry *e = QTAILQ_LAST(&s->events, events);
|
struct MTPMonEntry *e = QTAILQ_LAST(&s->events, events);
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
Loading…
Reference in New Issue
Block a user