Print this page
4833 Remove volrmmount
4845 rm(u)mount don't always print mount/unmount errors
4846 HAL partition names don't match real parition names
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 /*
  27  * Vold compatibility for rmvolmgr: emulate old commands as well as
  28  * action_filemgr.so to notify legacy apps via /tmp/.removable pipes.
  29  * A lot of this code is copied verbatim from vold sources.
  30  *
  31  * Here's the original description of action_filemgr.so:
  32  *
  33  * action_filemgr.so - filemgr interface routines for rmmount
  34  *
  35  * This shared object allows rmmount to communicate with filemgr.
  36  * This is done by communicating over a named pipe that filemgr
  37  * creates in directory NOTIFY_DIR.  The name of the pipe must
  38  * begin with NOTIFY_NAME.  This source file contains #define
  39  * compiler directives set the values of NOTIFY_DIR and NOTIFY_NAME.
  40  *
  41  * After a partition on a medium has been mounted as a result of
  42  * either insertion or remounting of the medium, the action()
  43  * method creates a file named with the symbolic name of the


 113 static char     mnt_userdir[MAXPATHLEN];
 114 
 115 /*
 116  * Private attribute types and attributes.
 117  */
 118 static const char notify_characters[] = {
 119         'e',
 120         'i',
 121         'r',
 122         'u'
 123 };
 124 
 125 static const char *result_strings[] = {
 126         "FALSE",
 127         "TRUE"
 128 };
 129 
 130 #define NOTIFY_DIR      "/tmp/.removable"       /* dir where filemgr looks */
 131 #define NOTIFY_NAME     "notify"                /* named pipe to talk over */
 132 
 133 static void     volrmmount_usage();
 134 static void     volcheck_usage();
 135 static int      vold_action(struct action_arg *aap);
 136 static void     vold_update_mountpoints(struct action_arg *aap);
 137 static char     *not_mountable(struct action_arg *aa);
 138 static int      create_one_notify_file(char *fstype,
 139                                 char *mount_point,
 140                                 char *notify_file,
 141                                 char *raw_partitionp,
 142                                 char *reason,
 143                                 char *symdev);
 144 static int      create_notify_files(struct action_arg **aa);
 145 static boolean_t notify_clients(action_t action, int do_notify);
 146 static void     popdir(int fd);
 147 static int      pushdir(const char *dir);
 148 static boolean_t remove_notify_files(struct action_arg **aa);
 149 
 150 /*
 151  * should be called once from main()
 152  */
 153 /* ARGSUSED */


   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  *
  21  *
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2014 Andrew Stormont
  26  */
  27 
  28 /*
  29  * Vold compatibility for rmvolmgr: emulate old commands as well as
  30  * action_filemgr.so to notify legacy apps via /tmp/.removable pipes.
  31  * A lot of this code is copied verbatim from vold sources.
  32  *
  33  * Here's the original description of action_filemgr.so:
  34  *
  35  * action_filemgr.so - filemgr interface routines for rmmount
  36  *
  37  * This shared object allows rmmount to communicate with filemgr.
  38  * This is done by communicating over a named pipe that filemgr
  39  * creates in directory NOTIFY_DIR.  The name of the pipe must
  40  * begin with NOTIFY_NAME.  This source file contains #define
  41  * compiler directives set the values of NOTIFY_DIR and NOTIFY_NAME.
  42  *
  43  * After a partition on a medium has been mounted as a result of
  44  * either insertion or remounting of the medium, the action()
  45  * method creates a file named with the symbolic name of the


 115 static char     mnt_userdir[MAXPATHLEN];
 116 
 117 /*
 118  * Private attribute types and attributes.
 119  */
 120 static const char notify_characters[] = {
 121         'e',
 122         'i',
 123         'r',
 124         'u'
 125 };
 126 
 127 static const char *result_strings[] = {
 128         "FALSE",
 129         "TRUE"
 130 };
 131 
 132 #define NOTIFY_DIR      "/tmp/.removable"       /* dir where filemgr looks */
 133 #define NOTIFY_NAME     "notify"                /* named pipe to talk over */
 134 

 135 static void     volcheck_usage();
 136 static int      vold_action(struct action_arg *aap);
 137 static void     vold_update_mountpoints(struct action_arg *aap);
 138 static char     *not_mountable(struct action_arg *aa);
 139 static int      create_one_notify_file(char *fstype,
 140                                 char *mount_point,
 141                                 char *notify_file,
 142                                 char *raw_partitionp,
 143                                 char *reason,
 144                                 char *symdev);
 145 static int      create_notify_files(struct action_arg **aa);
 146 static boolean_t notify_clients(action_t action, int do_notify);
 147 static void     popdir(int fd);
 148 static int      pushdir(const char *dir);
 149 static boolean_t remove_notify_files(struct action_arg **aa);
 150 
 151 /*
 152  * should be called once from main()
 153  */
 154 /* ARGSUSED */