]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - knowndrives.h
Imported Upstream version 5.38+svn2879
[mirror_smartmontools-debian.git] / knowndrives.h
index 8c7447e9b6d2d44324f079d421a05ae23d5f1aea..3908e40f918eafbd54e46eef96f586af44456c5c 100644 (file)
@@ -5,6 +5,7 @@
  * Address of support mailing list: smartmontools-support@lists.sourceforge.net
  *
  * Copyright (C) 2003-8 Philip Williams, Bruce Allen
+ * Copyright (C) 2008   Christian Franke <smartmontools-support@lists.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #ifndef KNOWNDRIVES_H_
 #define KNOWNDRIVES_H_
 
-#define KNOWNDRIVES_H_CVSID "$Id: knowndrives.h,v 1.18 2008/03/04 22:09:47 ballen4705 Exp $\n"
+#define KNOWNDRIVES_H_CVSID "$Id: knowndrives.h,v 1.23 2009/04/16 21:24:08 chrfranke Exp $\n"
 
 /* Structure used to store settings for specific drives in knowndrives[]. The
  * elements are used in the following ways:
  *
  *  modelfamily     Informal string about the model family/series of a 
- *                  device. Set to NULL if no info (apart from device id)
+ *                  device. Set to "" if no info (apart from device id)
  *                  known.
  *  modelregexp     POSIX regular expression to match the model of a device.
- *                  This should never be NULL (except to terminate the
- *                  knowndrives array).
+ *                  This should never be "".
  *  firmwareregexp  POSIX regular expression to match a devices's firmware
- *                  version.  This is optional and should be NULL if it is not
- *                  to be used.  If it is non-NULL then it will be used to
+ *                  version.  This is optional and should be "" if it is not
+ *                  to be used.  If it is nonempty then it will be used to
  *                  narrow the set of devices matched by modelregexp.
  *  warningmsg      A message that may be displayed for matching drives.  For
  *                  example, to inform the user that they may need to apply a
  *                  firmware patch.
- *  vendoropts      Pointer to first element of an array of vendor-specific
- *                  option attribute/value pairs that should be set for a
- *                  matching device unless the user has requested otherwise.
- *                  The user's own settings override these.  The array should
- *                  be terminated with the entry {0,0}.
- *  specialpurpose  Pointer to a function that defines some additional action
- *                  that may be taken for matching devices.
- *  functiondesc    A description of the effect of the specialpurpose
- *                  function.  Used by showpresets() and showallpresets() to
- *                  make the output more informative.
+ *  presets         String with vendor-specific attribute ('-v') and firmware
+ *                  bug fix ('-F') options.  Same syntax as in smartctl command
+ *                  line.  The user's own settings override these.
  */
-typedef struct drivesettings_s {
+struct drive_settings {
   const char * modelfamily;
   const char * modelregexp;
   const char * firmwareregexp;
   const char * warningmsg;
-  const unsigned char (* vendoropts)[2];
-  void (* specialpurpose)(smartmonctrl *);
-  const char * functiondesc;
-} drivesettings;
-
-/* Table of settings for known drives.  Defined in knowndrives.c. */
-extern const drivesettings knowndrives[];
+  const char * presets;
+};
 
 // Searches knowndrives[] for a drive with the given model number and firmware
 // string.
-int lookupdrive(const char *model, const char *firmware);
+const drive_settings * lookup_drive(const char * model, const char * firmware);
 
 // Shows the presets (if any) that are available for the given drive.
-void showpresets(const struct ata_identify_device *drive);
+void show_presets(const ata_identify_device * drive, bool fix_swapped_id);
 
 // Shows all presets for drives in knowndrives[].
-// Returns <0 on syntax error in regular expressions.
-int showallpresets(void);
+// Returns #syntax errors.
+int showallpresets();
 
 // Shows all matching presets for a drive in knowndrives[].
 // Returns # matching entries.
@@ -80,9 +68,14 @@ int showmatchingpresets(const char *model, const char *firmware);
 // Sets preset vendor attribute options in opts by finding the entry
 // (if any) for the given drive in knowndrives[].  Values that have
 // already been set in opts will not be changed.  Also sets options in
-// con.  Returns <0 if drive not recognized else index of drive in
-// database.
-int applypresets(const struct ata_identify_device *drive, unsigned char **opts,
-                  smartmonctrl *con);
+// con.  Returns false if drive not recognized.
+bool apply_presets(const ata_identify_device * drive, unsigned char * opts,
+                   unsigned char & fix_firmwarebug, bool fix_swapped_id);
+
+// Read drive database from file.
+bool read_drive_database(const char * path);
+
+// Read drive databases from standard places.
+bool read_default_drive_databases();
 
 #endif