~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to gio/kqueue/kqueue-exclusions.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
  Copyright (c) 2012 Dmitry Matveev <me@dmitrymatveev.co.uk>
 
3
  Copyright (c) 2012 Antoine Jacoutot <ajacoutot@openbsd.org>
 
4
 
 
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
  of this software and associated documentation files (the "Software"), to deal
 
7
  in the Software without restriction, including without limitation the rights
 
8
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
  copies of the Software, and to permit persons to whom the Software is
 
10
  furnished to do so, subject to the following conditions:
 
11
 
 
12
  The above copyright notice and this permission notice shall be included in
 
13
  all copies or substantial portions of the Software.
 
14
 
 
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
21
  THE SOFTWARE.
 
22
*******************************************************************************/
 
23
 
 
24
#include <fcntl.h>
 
25
#include <glib.h>
 
26
#include <gio/gio.h>
 
27
#include "kqueue-exclusions.h"
 
28
 
 
29
static gboolean ke_debug_enabled = FALSE;
 
30
#define KE_W if (ke_debug_enabled) g_warning
 
31
 
 
32
/**
 
33
 * _ke_is_excluded:
 
34
 * @full_path - a path to file to check.
 
35
 *
 
36
 * Returns: TRUE if the file should be excluded from the kqueue-powered
 
37
 *      monitoring, FALSE otherwise.
 
38
 **/
 
39
gboolean
 
40
_ke_is_excluded (const char *full_path)
 
41
{
 
42
#if defined (O_EVTONLY)
 
43
  return FALSE;
 
44
#else
 
45
  GFile *f = NULL;
 
46
  GMount *mount = NULL;
 
47
 
 
48
  f = g_file_new_for_path (full_path);
 
49
 
 
50
  if (f != NULL) {
 
51
    mount = g_file_find_enclosing_mount (f, NULL, NULL);
 
52
    g_object_unref (f);
 
53
  }
 
54
 
 
55
  if ((mount != NULL && (g_mount_can_unmount (mount))) || g_str_has_prefix (full_path, "/mnt/"))
 
56
  {
 
57
    KE_W ("Excluding %s from kernel notification, falling back to poll", full_path);
 
58
    if (mount)
 
59
      g_object_unref (mount);
 
60
    return TRUE;
 
61
  }
 
62
  else
 
63
    return FALSE;
 
64
#endif
 
65
}