How can I modify storage-policy.fdi to add more mount option when the oprion is variable?

Rocky Zhang rocky at userful.com
Thu Jul 14 09:49:04 PDT 2005


Thank you so much.

I followed your approach, it works when I disable SELinux (Security-
Enhanced Linux). If I enable SELinux, which is default option during
installation, system add additional mount option
"fscontext=system_u:object_r:removable_t" and other all mount options I
set except "fs=$CURRENT_FILESYSTYPE" option when I hotplug in USB key
drive; But if I use "service haldaemon restart" to refresh hal, it add
the correct mount options as I expected. 

Thanks again.

Rocky

On Thu, 2005-07-14 at 09:39 +0400, Anton Farygin wrote:
> В письме Wed, 13 Jul 2005 15:30:34 -0600, Rocky Zhang
> написал:
> 
> > Hi Guys,
> > 
> > I installed Fedora Core 4 on my computer. And I recompiled submount
> > ( http://submount.sourceforge.net ) and installed, I'd like to use subfs
> > to manage all removable storage devices.
> > 
> > I looked into fstab-sync help documentation, and know that I can add my
> > own 10-storage-policy.fdi under /etc/hal/fdi/policy to manager entry to
> > fstab when hotplug some device. I want to use subfs when I hotplug in a
> > USB key drive. So I modified the policy file to use subfs as file system
> > to mount, one thing I can't do that I need add "fs=$CURRENT_FILESYSTYPE"
> > to the mount option. The CURRENT_FILESYSTYPE value should be the same as
> > volume.fstype, and it depends on the USBS key drive.
> > 
> 
> 
> need patched hal for using string options into
> volume.policy.mount_option.* or storage.policy.mount_option.*
> 
> -         <merge key="volume.policy.mount_filesystem" type="copy_property">volume.fstype</merge>
> +         <merge key="volume.policy.mount_filesystem" type="string">subfs</merge>
> +          <merge key="volume.policy.mount_option.fs" type="copy_property">volume.fstype</merge>
> 
> patch for storage:
> 
> diff -urN hal-0.5.3.orig/libhal-storage/libhal-storage.c hal-0.5.3/libhal-storage/libhal-storage.c
> --- hal-0.5.3.orig/libhal-storage/libhal-storage.c      2005-06-28 19:47:51 +0400
> +++ hal-0.5.3/libhal-storage/libhal-storage.c   2005-07-13 16:53:07 +0400
> @@ -1529,7 +1529,7 @@
>  
>                 type = libhal_psi_get_type (&it);
>                 key = libhal_psi_get_key (&it);
> -               if (libhal_psi_get_type (&it) == LIBHAL_PROPERTY_TYPE_BOOLEAN &&
> +               if ((type == LIBHAL_PROPERTY_TYPE_BOOLEAN || type  == LIBHAL_PROPERTY_TYPE_STRING) &&
>                     strncmp (key, namespace, namespace_len - 1) == 0) {
>                         const char *option = key + namespace_len - 1;
>                         char *location;
> @@ -1550,6 +1550,28 @@
>                                 if (is_imply_opt)
>                                         continue;
>                         }
> +
> +                       if (type == LIBHAL_PROPERTY_TYPE_STRING)
> +                           {
> +                               char* value;
> +                               LIBHAL_PROP_EXTRACT_BEGIN;
> +                               LIBHAL_PROP_EXTRACT_STRING (key,value);
> +                               LIBHAL_PROP_EXTRACT_END;
> +                               fprintf(stderr,"option: %s=%s\n",option,value);
> +                               if (strlen(value) > 0)
> +                                   {
> +                                       location = strstr (options_string, option);
> +                                       if (location == NULL) {
> +                                           if (strlen (options_string) > 0)
> +                                               strcat_len (options_string, ",", options_max_len);
> +                                           strcat_len (options_string, option, options_max_len);
> +                                           strcat_len (options_string, "=", options_max_len);
> +                                           strcat_len (options_string, value, options_max_len);
> +                                       }
> +
> +
> +                                   }
> +                           }
>  
>                         if (libhal_psi_get_bool (&it)) {
>                                 /* see if option is already there */
> 
> 
> _______________________________________________
> hal mailing list
> hal at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/hal

_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list