Magellan Linux

Annotation of /trunk/hal/patches/hal-0.5.7.1-autofs-subfs.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (hide annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years, 1 month ago) by niro
File size: 3051 byte(s)
-import

1 niro 144 diff -Naur hal-0.5.7-orig/hald/linux2/blockdev.c hal-0.5.7/hald/linux2/blockdev.c
2     --- hal-0.5.7-orig/hald/linux2/blockdev.c 2006-02-24 07:29:06 +0300
3     +++ hal-0.5.7/hald/linux2/blockdev.c 2006-06-02 23:45:51 +0400
4     @@ -185,6 +185,7 @@
5     dev_t devt = makedev(0, 0);
6     GSList *volumes = NULL;
7     GSList *volume;
8     + GSList *autofs_mounts = NULL;
9    
10     /* open /proc/mounts */
11     g_snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
12     @@ -205,6 +206,43 @@
13     while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
14     struct stat statbuf;
15    
16     + /* If this is a nfs mount or autofs
17     + * (fstype == 'nfs' || fstype == 'autofs')
18     + * ignore the mount. Reason:
19     + * 1. we don't list nfs devices in HAL
20     + * 2. more problematic: stat on mountpoints with
21     + * 'stale nfs handle' never come
22     + * back and block complete HAL and all applications
23     + * using HAL fail.
24     + * 3. autofs and HAL butt heads causing drives to never
25     + * be unmounted
26     + */
27     + if (strcmp(mnt.mnt_type, "nfs") == 0)
28     + continue;
29     +
30     + /* If this is an autofs mount (fstype == 'autofs' or fstype == 'subfs')
31     + * store the mount in a list for later use.
32     + * On mounts managed by autofs or subfs accessing files below the mount
33     + * point cause the mount point to be remounted after an
34     + * unmount. We keep the list so we do not check for
35     + * the .created-by-hal file on mounts under autofs or subfs mount points
36     + */
37     + if (strcmp(mnt.mnt_type, "autofs") == 0 ||
38     + strcmp(mnt.mnt_type, "subfs") == 0) {
39     + char *mnt_dir;
40     +
41     + if (mnt.mnt_dir[strlen (mnt.mnt_dir) - 1] != '/')
42     + mnt_dir = g_strdup_printf ("%s/", mnt.mnt_dir);
43     + else
44     + mnt_dir = g_strdup (mnt.mnt_dir);
45     +
46     + autofs_mounts = g_slist_append (autofs_mounts,
47     + mnt_dir);
48     +
49     +
50     + continue;
51     + }
52     +
53     /* check the underlying device of the mount point */
54     if (stat (mnt.mnt_dir, &statbuf) != 0)
55     continue;
56     @@ -242,6 +280,7 @@
57     HalDevice *dev;
58     char *mount_point;
59     char *mount_point_hal_file;
60     + GSList *autofs_node;
61    
62     dev = HAL_DEVICE (volume->data);
63     mount_point = g_strdup (hal_device_property_get_string (dev, "volume.mount_point"));
64     @@ -251,8 +290,20 @@
65     device_property_atomic_update_end ();
66     HAL_INFO (("set %s to unmounted", hal_device_get_udi (dev)));
67    
68     + /* check to see if mount point falls under autofs */
69     + autofs_node = autofs_mounts;
70     + while (autofs_node != NULL) {
71     + char *am = (char *)autofs_node->data;
72     +
73     + if (strncmp (am, mount_point, strlen (am)) == 0);
74     + break;
75     +
76     + autofs_node = autofs_node->next;
77     + }
78     +
79     mount_point_hal_file = g_strdup_printf ("%s/.created-by-hal", mount_point);
80     - if (g_file_test (mount_point_hal_file, G_FILE_TEST_EXISTS)) {
81     + if (!autofs_node &&
82     + g_file_test (mount_point_hal_file, G_FILE_TEST_EXISTS)) {
83     char *cleanup_stdin;
84     char *extra_env[2];
85    
86     @@ -279,6 +330,8 @@
87     g_free (mount_point);
88     }
89     g_slist_free (volumes);
90     + g_slist_foreach (autofs_mounts, (GFunc) g_free, NULL);
91     + g_slist_free (autofs_mounts);
92     exit:
93     endmntent (f);
94     }