Go to the documentation of this file.
38 #include <sys/inotify.h>
47 #ifndef HAVE_INOTIFY_INIT1
62 #define INOTIFY_MASK_DIR (IN_MOVED_TO | IN_ATTRIB | IN_CLOSE_WRITE | IN_ISDIR)
63 #define INOTIFY_MASK_FILE IN_CLOSE_WRITE
65 #define EVENT_BUFLEN MAX(4096, sizeof(struct inotify_event) + NAME_MAX + 1)
163 #ifdef HAVE_INOTIFY_INIT1
164 INotifyFd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
213 monitor->
desc = descriptor;
229 memset(info, 0,
sizeof(*info));
262 monitor = monitor->
next;
279 while (iter && (iter->
desc != desc))
298 iter->
desc = new_desc;
364 fmt =
"%s/.mh_sequences";
371 if (stat(info->
path, &sb) != 0)
375 while (iter && ((iter->
st_ino != sb.st_ino) || (iter->
st_dev != sb.st_dev)))
402 char buf[
EVENT_BUFLEN] __attribute__((aligned(__alignof__(
struct inotify_event))));
420 bool input_ready =
false;
435 const struct inotify_event *
event = NULL;
439 int len = read(
INotifyFd, buf,
sizeof(buf));
445 errno, strerror(errno));
450 while (ptr < (buf + len))
452 event = (
const struct inotify_event *) ptr;
454 event->wd, event->mask);
455 if (event->mask & IN_IGNORED)
459 ptr +=
sizeof(
struct inotify_event) + event->len;
498 ((desc = inotify_add_watch(
INotifyFd, info.
path, mask)) == -1))
501 info.
path, errno, strerror(errno));
static void monitor_info_free(struct MonitorInfo *info)
Shutdown a file monitor.
bool MonitorFilesChanged
true after a monitored file has changed
static void monitor_delete(struct Monitor *monitor)
Free a file monitor.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
@ RESOLVE_RES_OK_NOTEXISTING
File exists, no monitor is attached.
static struct pollfd * PollFds
String manipulation buffer.
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
@ LL_DEBUG3
Log at debug level 3.
struct Mailbox * ctx_mailbox(struct Context *ctx)
wrapper to get the mailbox in a Context, or NULL
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Information about a monitored file.
#define INOTIFY_MASK_FILE
static int monitor_init(void)
Set up file monitoring.
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
int mutt_monitor_poll(void)
Check for filesystem changes.
@ RESOLVE_RES_OK_EXISTING
File exists, monitor is already attached.
enum MailboxType type
Mailbox type.
int MuttGetchTimeout
Timeout in ms for mutt_getch()
@ RESOLVE_RES_FAIL_NOMAILBOX
No Mailbox to work on.
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
@ MUTT_MH
'MH' Mailbox type
#define mutt_debug(LEVEL,...)
ResolveResult
Results for the Monitor functions.
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
static int mutt_poll_fd_remove(int fd)
Remove a file from the watch list.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
@ RESOLVE_RES_FAIL_NOTYPE
Can't identify Mailbox type.
static void monitor_info_init(struct MonitorInfo *info)
Set up a file monitor.
static void mutt_poll_fd_add(int fd, short events)
Add a file to the watch list.
struct Buffer path_buf
access via path only (maybe not initialized)
static enum ResolveResult monitor_resolve(struct MonitorInfo *info, struct Mailbox *m)
Get the monitor for a mailbox.
static int monitor_handle_ignore(int desc)
Listen for when a backup file is closed.
static struct Monitor * Monitor
MailboxType
Supported mailbox formats.
@ MUTT_MAILDIR
'Maildir' Mailbox type
static void monitor_check_free(void)
Close down file monitoring.
static int MonitorContextDescriptor
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
bool MonitorContextChanged
true after the current mailbox has changed
static size_t PollFdsCount
static struct Monitor * monitor_new(struct MonitorInfo *info, int descriptor)
Create a new file monitor.
@ LL_DEBUG2
Log at debug level 2.
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
@ RESOLVE_RES_FAIL_STAT
Can't stat() the Mailbox file.