hal/hald/linux2/probing probe-storage.c, 1.2, 1.3 probe-volume.c,
1.3, 1.4 shared.h, 1.1, 1.2
David Zeuthen
david at freedesktop.org
Wed Feb 16 14:25:22 PST 2005
- Previous message: hal/hald/linux2/addons addon-storage.c,1.2,1.3
- Next message: hal/volume_id Makefile.am, 1.2, 1.3 logging.h, 1.1, 1.2 luks.c, NONE,
1.1 luks.h, NONE, 1.1 volume_id.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald/linux2/probing
In directory gabe:/tmp/cvs-serv25568/hald/linux2/probing
Modified Files:
probe-storage.c probe-volume.c shared.h
Log Message:
2005-02-16 David Zeuthen <davidz at redhat.com>
* volume_id/luks.[ch]: New files (forgot to commit before)
* hald/linux2/probing/shared.h: Redefine logging a bit
* hald/linux2/probing/probe-volume.c: Use new shared.h logging;
implement volume_id_log and drive_id_log functions
* hald/linux2/probing/probe-storage.c: Use new shared.h logging;
implement volume_id_log and drive_id_log functions
* hald/linux2/addons/addon-storage.c: Use new shared.h logging
* drive_id/logging.h: Use drive_id_log function
* drive_id/drive_id.h (drive_id_log): Add drive_id_log prototype
Index: probe-storage.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/probe-storage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- probe-storage.c 11 Feb 2005 22:01:08 -0000 1.2
+++ probe-storage.c 16 Feb 2005 22:25:20 -0000 1.3
@@ -46,11 +46,25 @@
#include "drive_id/drive_id.h"
#include "volume_id/volume_id.h"
-
#include "linux_dvd_rw_utils.h"
#include "shared.h"
+void
+volume_id_log (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ _do_dbg (format, args);
+}
+
+void
+drive_id_log (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ _do_dbg (format, args);
+}
/** Check if a filesystem on a special device file is mounted
*
@@ -114,6 +128,9 @@
if ((drive_type = getenv ("HAL_PROP_STORAGE_DRIVE_TYPE")) == NULL)
goto out;
+ if ((getenv ("HALD_VERBOSE")) != NULL)
+ is_verbose = TRUE;
+
if (argc == 2 && strcmp (argv[1], "--only-check-for-media") == 0)
only_check_for_fs = TRUE;
else
@@ -190,7 +207,7 @@
int read_speed, write_speed;
if( ioctl (fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS) < 0 ) {
- HAL_ERROR (("CDROM_SET_OPTIONS failed: %s\n", strerror(errno)));
+ dbg ("Error: CDROM_SET_OPTIONS failed: %s\n", strerror(errno));
goto out;
}
@@ -319,7 +336,7 @@
}
if (fd < 0) {
- HAL_INFO (("open failed for %s: %s", device_file, strerror (errno)));
+ dbg ("open failed for %s: %s", device_file, strerror (errno));
goto out;
}
@@ -352,7 +369,7 @@
break;
case -1:
- HAL_ERROR(("CDROM_DRIVE_STATUS failed: %s\n", strerror(errno)));
+ dbg ("Error: CDROM_DRIVE_STATUS failed: %s\n", strerror(errno));
break;
default:
Index: probe-volume.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/probe-volume.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- probe-volume.c 16 Feb 2005 20:16:55 -0000 1.3
+++ probe-volume.c 16 Feb 2005 22:25:20 -0000 1.4
@@ -41,6 +41,8 @@
#include <linux/kdev_t.h>
#include <linux/cdrom.h>
#include <linux/fs.h>
+#include <time.h>
+#include <sys/time.h>
#include "libhal/libhal.h"
@@ -52,6 +54,14 @@
#include "shared.h"
+void
+volume_id_log (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ _do_dbg (format, args);
+}
+
static void
set_volume_id_values (LibHalContext *ctx, const char *udi, struct volume_id *vid)
{
@@ -86,18 +96,18 @@
}
libhal_device_set_property_string (ctx, udi, "volume.fsusage", usage, &error);
- HAL_INFO (("volume.fsusage = '%s'", usage));
+ dbg ("volume.fsusage = '%s'", usage);
libhal_device_set_property_string (ctx, udi, "volume.fstype", vid->type, &error);
- HAL_INFO (("volume.fstype = '%s'", vid->type));
+ dbg ("volume.fstype = '%s'", vid->type);
if (vid->type_version[0] != '\0') {
libhal_device_set_property_string (ctx, udi, "volume.fsversion", vid->type_version, &error);
- HAL_INFO (("volume.fsversion = '%s'", vid->type_version));
+ dbg ("volume.fsversion = '%s'", vid->type_version);
}
libhal_device_set_property_string (ctx, udi, "volume.uuid", vid->uuid, &error);
- HAL_INFO (("volume.uuid = '%s'", vid->uuid));
+ dbg ("volume.uuid = '%s'", vid->uuid);
libhal_device_set_property_string (ctx, udi, "volume.label", vid->label, &error);
- HAL_INFO (("volume.label = '%s'", vid->label));
+ dbg ("volume.label = '%s'", vid->label);
if (vid->label[0] != '\0') {
libhal_device_set_property_string (ctx, udi, "info.product", vid->label, &error);
@@ -153,6 +163,9 @@
else
is_disc = FALSE;
+ if ((getenv ("HALD_VERBOSE")) != NULL)
+ is_verbose = TRUE;
+
dbus_error_init (&error);
if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
goto out;
@@ -197,7 +210,7 @@
vid = volume_id_open_node (stordev_dev_file);
if (vid != NULL) {
if (volume_id_probe_msdos_part_table (vid, 0) == 0) {
- HAL_INFO (("Number of partitions = %d", vid->partition_count));
+ dbg ("Number of partitions = %d", vid->partition_count);
if (partition_number > 0 && partition_number <= vid->partition_count) {
struct volume_id_partition *p;
@@ -224,8 +237,8 @@
}
} else {
- HAL_WARNING (("partition_number=%d not in [0;%d[",
- partition_number, vid->partition_count));
+ dbg ("warning: partition_number=%d not in [0;%d[",
+ partition_number, vid->partition_count);
}
}
volume_id_close(vid);
@@ -235,11 +248,11 @@
/* block size and total size */
if (ioctl (fd, BLKSSZGET, &block_size) == 0) {
- HAL_INFO (("volume.block_size = %d", block_size));
+ dbg ("volume.block_size = %d", block_size);
libhal_device_set_property_int (ctx, udi, "volume.block_size", block_size, &error);
}
if (ioctl (fd, BLKGETSIZE64, &vol_size) == 0) {
- HAL_INFO (("volume.size = %llu", vol_size));
+ dbg ("volume.size = %llu", vol_size);
libhal_device_set_property_uint64 (ctx, udi, "volume.size", vol_size, &error);
}
@@ -268,28 +281,28 @@
switch (type) {
case CDS_AUDIO: /* audio CD */
libhal_device_set_property_bool (ctx, udi, "volume.disc.has_audio", TRUE, &error);
- HAL_INFO (("Disc in %s has audio", device_file));
+ dbg ("Disc in %s has audio", device_file);
break;
case CDS_MIXED: /* mixed mode CD */
libhal_device_set_property_bool (ctx, udi, "volume.disc.has_audio", TRUE, &error);
libhal_device_set_property_bool (ctx, udi, "volume.disc.has_data", TRUE, &error);
- HAL_INFO (("Disc in %s has audio+data", device_file));
+ dbg ("Disc in %s has audio+data", device_file);
break;
case CDS_DATA_1: /* data CD */
case CDS_DATA_2:
case CDS_XA_2_1:
case CDS_XA_2_2:
libhal_device_set_property_bool (ctx, udi, "volume.disc.has_data", TRUE, &error);
- HAL_INFO (("Disc in %s has data", device_file));
+ dbg ("Disc in %s has data", device_file);
break;
case CDS_NO_INFO: /* blank or invalid CD */
libhal_device_set_property_bool (ctx, udi, "volume.disc.is_blank", TRUE, &error);
- HAL_INFO (("Disc in %s is blank", device_file));
+ dbg ("Disc in %s is blank", device_file);
break;
default: /* should never see this */
libhal_device_set_property_string (ctx, udi, "volume.disc_type", "unknown", &error);
- HAL_INFO (("Disc in %s returned unknown CDROM_DISC_STATUS", device_file));
+ dbg ("Disc in %s returned unknown CDROM_DISC_STATUS", device_file);
break;
}
@@ -297,7 +310,7 @@
* http://www.t10.org/drafts.htm#mmc3
*/
type = get_disc_type (fd);
- HAL_INFO (("get_disc_type returned 0x%02x", type));
+ dbg ("get_disc_type returned 0x%02x", type);
if (type != -1) {
switch (type) {
case 0x08: /* CD-ROM */
Index: shared.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/shared.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- shared.h 10 Feb 2005 21:43:07 -0000 1.1
+++ shared.h 16 Feb 2005 22:25:20 -0000 1.2
@@ -5,109 +5,46 @@
#include <time.h>
#include <sys/time.h>
+static dbus_bool_t is_verbose = FALSE;
-static int priority;
-static const char *file;
-static int line;
-static const char *function;
-
-static int is_enabled = 1;
-
-
-
-/** Logging levels for HAL daemon
- */
-enum {
- HAL_LOGPRI_TRACE = (1 << 0), /**< function call sequences */
- HAL_LOGPRI_DEBUG = (1 << 1), /**< debug statements in code */
- HAL_LOGPRI_INFO = (1 << 2), /**< informational level */
- HAL_LOGPRI_WARNING = (1 << 3), /**< warnings */
- HAL_LOGPRI_ERROR = (1 << 4) /**< error */
-};
-
-/** Setup logging entry
- *
- * @param priority Logging priority, one of HAL_LOGPRI_*
- * @param file Name of file where the log entry originated
- * @param line Line number of file
- * @param function Name of function
- */
-static void
-logger_setup (int _priority, const char *_file, int _line, const char *_function)
-{
- priority = _priority;
- file = _file;
- line = _line;
- function = _function;
-}
-
-/** Emit logging entry
- *
- * @param format Message format string, printf style
- * @param ... Parameters for message, printf style
- */
static void
-logger_emit (const char *format, ...)
+_do_dbg (const char *format, va_list args)
{
- va_list args;
char buf[512];
- char *pri;
char tbuf[256];
struct timeval tnow;
struct tm *tlocaltime;
struct timezone tzone;
+ static pid_t pid = -1;
- if (!is_enabled)
+ if (!is_verbose)
return;
- va_start (args, format);
- vsnprintf (buf, sizeof (buf), format, args);
+ if ((int) pid == -1)
+ pid = getpid ();
- switch (priority) {
- case HAL_LOGPRI_TRACE:
- pri = "[T]";
- break;
- case HAL_LOGPRI_DEBUG:
- pri = "[D]";
- break;
- case HAL_LOGPRI_INFO:
- pri = "[I]";
- break;
- case HAL_LOGPRI_WARNING:
- pri = "[W]";
- break;
- default: /* explicit fallthrough */
- case HAL_LOGPRI_ERROR:
- pri = "[E]";
- break;
- }
+ vsnprintf (buf, sizeof (buf), format, args);
gettimeofday (&tnow, &tzone);
tlocaltime = localtime (&tnow.tv_sec);
strftime (tbuf, sizeof (tbuf), "%H:%M:%S", tlocaltime);
- /** @todo Make programmatic interface to logging */
- if (priority != HAL_LOGPRI_TRACE)
- fprintf (stderr, "%s.%03d %s %s:%d: %s\n", tbuf, (int)(tnow.tv_usec/1000), pri, file, line, buf);
+ fprintf (stderr, "%d: %s.%03d: %s", pid, tbuf, (int)(tnow.tv_usec/1000), buf);
va_end (args);
}
+static void
+_dbg (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ _do_dbg (format, args);
+}
-/** Trace logging macro */
-#define HAL_TRACE(expr) do {logger_setup(HAL_LOGPRI_TRACE, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0)
-
-/** Debug information logging macro */
-#define HAL_DEBUG(expr) do {logger_setup(HAL_LOGPRI_DEBUG, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0)
-
-/** Information level logging macro */
-#define HAL_INFO(expr) do {logger_setup(HAL_LOGPRI_INFO, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0)
-
-/** Warning level logging macro */
-#define HAL_WARNING(expr) do {logger_setup(HAL_LOGPRI_WARNING, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0)
-
-/** Error leve logging macro */
-#define HAL_ERROR(expr) do {logger_setup(HAL_LOGPRI_ERROR, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0)
-
+#define dbg(format, arg...) \
+ do { \
+ _dbg ("%s:%d: " format "\n", __FILE__, __LINE__, ## arg); \
+ } while (0)
#endif
- Previous message: hal/hald/linux2/addons addon-storage.c,1.2,1.3
- Next message: hal/volume_id Makefile.am, 1.2, 1.3 logging.h, 1.1, 1.2 luks.c, NONE,
1.1 luks.h, NONE, 1.1 volume_id.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list