Print this page
8485 Remove set but unused variables in usr/src/cmd
   1 /***************************************************************************
   2  *
   3  * addon-storage.c : watch removable media state changes
   4  *

   5  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   6  * Use is subject to license terms.
   7  *
   8  * Licensed under the Academic Free License version 2.1
   9  *
  10  **************************************************************************/
  11 
  12 #ifdef HAVE_CONFIG_H
  13 #  include <config.h>
  14 #endif
  15 
  16 #include <errno.h>
  17 #include <string.h>
  18 #include <strings.h>
  19 #include <stdlib.h>
  20 #include <stdio.h>
  21 #include <sys/ioctl.h>
  22 #include <sys/types.h>
  23 #include <sys/stat.h>
  24 #include <sys/types.h>


 301                 return;
 302         }
 303 
 304         priv_emptyset(lPrivSet);
 305 
 306         if (setppriv(PRIV_SET, PRIV_LIMIT, lPrivSet) != 0) {
 307                 return;
 308         }
 309 
 310         priv_freeset(lPrivSet);
 311 }
 312 
 313 int 
 314 main (int argc, char *argv[])
 315 {
 316         char *device_file, *raw_device_file;
 317         DBusError error;
 318         char *bus;
 319         char *drive_type;
 320         int state, last_state;
 321         char *support_media_changed_str;
 322         int support_media_changed;
 323         int fd = -1;
 324 
 325         if ((udi = getenv ("UDI")) == NULL)
 326                 goto out;
 327         if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
 328                 goto out;
 329         if ((raw_device_file = getenv ("HAL_PROP_BLOCK_SOLARIS_RAW_DEVICE")) == NULL)
 330                 goto out;
 331         if ((bus = getenv ("HAL_PROP_STORAGE_BUS")) == NULL)
 332                 goto out;
 333         if ((drive_type = getenv ("HAL_PROP_STORAGE_DRIVE_TYPE")) == NULL)
 334                 goto out;
 335         if ((devfs_path = getenv ("HAL_PROP_SOLARIS_DEVFS_PATH")) == NULL)
 336                 goto out;
 337 
 338         drop_privileges ();
 339 
 340         setup_logger ();
 341 
 342         sysevent_init ();
 343 
 344         support_media_changed_str = getenv ("HAL_PROP_STORAGE_CDROM_SUPPORT_MEDIA_CHANGED");
 345         if (support_media_changed_str != NULL && strcmp (support_media_changed_str, "true") == 0)
 346                 support_media_changed = TRUE;
 347         else
 348                 support_media_changed = FALSE;
 349 
 350         dbus_error_init (&error);
 351 
 352         if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 353                 goto out;
 354         }
 355         my_dbus_error_free (&error);
 356 
 357         if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
 358                 goto out;
 359         }
 360         my_dbus_error_free (&error);
 361 
 362         printf ("Doing addon-storage for %s (bus %s) (drive_type %s) (udi %s)\n", device_file, bus, drive_type, udi);
 363 
 364         last_state = state = DKIO_NONE;
 365 
 366         /* Linux version of this addon attempts to re-open the device O_EXCL
 367          * every 2 seconds, trying to figure out if some other app,
 368          * like a cd burner, is using the device. Aside from questionable
 369          * value of this (apps should use HAL's locked property or/and


   1 /***************************************************************************
   2  *
   3  * addon-storage.c : watch removable media state changes
   4  *
   5  * Copyright 2017 Gary Mills
   6  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   7  * Use is subject to license terms.
   8  *
   9  * Licensed under the Academic Free License version 2.1
  10  *
  11  **************************************************************************/
  12 
  13 #ifdef HAVE_CONFIG_H
  14 #  include <config.h>
  15 #endif
  16 
  17 #include <errno.h>
  18 #include <string.h>
  19 #include <strings.h>
  20 #include <stdlib.h>
  21 #include <stdio.h>
  22 #include <sys/ioctl.h>
  23 #include <sys/types.h>
  24 #include <sys/stat.h>
  25 #include <sys/types.h>


 302                 return;
 303         }
 304 
 305         priv_emptyset(lPrivSet);
 306 
 307         if (setppriv(PRIV_SET, PRIV_LIMIT, lPrivSet) != 0) {
 308                 return;
 309         }
 310 
 311         priv_freeset(lPrivSet);
 312 }
 313 
 314 int 
 315 main (int argc, char *argv[])
 316 {
 317         char *device_file, *raw_device_file;
 318         DBusError error;
 319         char *bus;
 320         char *drive_type;
 321         int state, last_state;


 322         int fd = -1;
 323 
 324         if ((udi = getenv ("UDI")) == NULL)
 325                 goto out;
 326         if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
 327                 goto out;
 328         if ((raw_device_file = getenv ("HAL_PROP_BLOCK_SOLARIS_RAW_DEVICE")) == NULL)
 329                 goto out;
 330         if ((bus = getenv ("HAL_PROP_STORAGE_BUS")) == NULL)
 331                 goto out;
 332         if ((drive_type = getenv ("HAL_PROP_STORAGE_DRIVE_TYPE")) == NULL)
 333                 goto out;
 334         if ((devfs_path = getenv ("HAL_PROP_SOLARIS_DEVFS_PATH")) == NULL)
 335                 goto out;
 336 
 337         drop_privileges ();
 338 
 339         setup_logger ();
 340 
 341         sysevent_init ();
 342 






 343         dbus_error_init (&error);
 344 
 345         if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 346                 goto out;
 347         }
 348         my_dbus_error_free (&error);
 349 
 350         if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
 351                 goto out;
 352         }
 353         my_dbus_error_free (&error);
 354 
 355         printf ("Doing addon-storage for %s (bus %s) (drive_type %s) (udi %s)\n", device_file, bus, drive_type, udi);
 356 
 357         last_state = state = DKIO_NONE;
 358 
 359         /* Linux version of this addon attempts to re-open the device O_EXCL
 360          * every 2 seconds, trying to figure out if some other app,
 361          * like a cd burner, is using the device. Aside from questionable
 362          * value of this (apps should use HAL's locked property or/and