/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mailbox-list-fs.h"
/* Assume that if atime < mtime, there are new mails. If it's good enough for
UW-IMAP, it's good enough for us. */
static int
enum mailbox_info_flags *flags_r)
{
bool mailbox_files;
switch (type) {
/* non-directories aren't valid */
return 0;
break;
}
return 0;
} else {
/* non-selectable. probably either access denied, or
symlink destination not found. don't bother logging
errors. */
*flags_r |= MAILBOX_NOSELECT;
return 1;
}
}
/* temporary NFS file */
} else {
}
return 0;
}
/* ok, we've got a directory. see what we can do about it. */
/* 1st link is "."
2nd link is ".."
3rd link is either child mailbox or mailbox dir
rest of the links are child mailboxes
if mailboxes are files, then 3+ links are all child mailboxes.
*/
*flags_r |= MAILBOX_NOSELECT;
return 1;
}
/* we have at least one directory. see if this mailbox is selectable */
if (mailbox_files) {
} else {
}
} else {
/* now we know what link count 3 means. */
else
*flags_r |= MAILBOX_CHILDREN;
}
*flags_r |= MAILBOX_SELECT;
return 1;
}
static bool
{
const char *inbox_path;
return FALSE;
&inbox_path) <= 0)
i_unreached();
}
enum mailbox_list_file_type type,
enum mailbox_info_flags *flags_r)
{
const char *path;
*flags_r = 0;
/* maildir_name is set: This is the simple case that works for
all mail storage formats, because the only thing that
matters for existence or child checks is whether the
maildir_name exists or not. For example with Maildir this
doesn't care whether the "cur" directory exists; as long
as the parent maildir_name exists, the Maildir is
selectable. */
}
/* maildir_name is not set: Now we (may) need to use storage-specific
code to determine whether the mailbox is selectable or if it has
children.
We're here also when iterating from index directory, because even
though maildir_name is set, it's not used for index directory.
*/
*flags_r |= MAILBOX_NOSELECT;
return 0;
}
switch (type) {
/* We know that we're looking at a directory. If the storage
uses files, it has to be a \NoSelect directory. */
*flags_r |= MAILBOX_NOSELECT;
return 1;
}
break;
/* We know that we're looking at a file. If the storage
doesn't use files, it's not a mailbox and we want to skip
it. */
return 0;
}
break;
default:
break;
}
/* we've done all filtering we can before stat()ing */
return 0;
*flags_r |= MAILBOX_NOSELECT;
return 1;
} else {
/* non-selectable. probably either access denied, or
symlink destination not found. don't bother logging
errors. */
path);
return -1;
}
}
/* temporary NFS file */
return 0;
}
return 0;
}
/* looks like a valid mailbox file */
/* it's possible for INBOX to have child
mailboxes as long as the inbox file itself
isn't in <mail root>/INBOX */
} else {
}
/* Return mailbox files as always existing. The current
mailbox_exists() code would do the same stat() anyway
without further checks, so might as well avoid the second
stat(). */
*flags_r |= MAILBOX_SELECT;
return 1;
}
/* This is a directory */
/* We should get here only if type is
MAILBOX_LIST_FILE_TYPE_UNKNOWN because the filesystem didn't
return the type. Normally this should have already been
handled by the MAILBOX_LIST_FILE_TYPE_DIR check above. */
*flags_r |= MAILBOX_NOSELECT;
return 1;
}
/* This mailbox format doesn't use any special directories
the directory's link count to determine whether there are
children or not. The directory's link count equals the
number of subdirectories it has. The first two links are
for "." and "..".
link count < 2 can happen with filesystems that don't
support link counts. we'll just ignore them for now.. */
*flags_r |= MAILBOX_CHILDREN;
}
return 1;
}