~ubuntu-branches/ubuntu/karmic/hddtemp/karmic

« back to all changes in this revision

Viewing changes to src/scsicmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno
  • Date: 2007-01-19 00:38:27 UTC
  • mfrom: (2.1.10 feisty)
  • Revision ID: james.westby@ubuntu.com-20070119003827-ch64quemh03mex0d
Tags: 0.3-beta15-34
* Relax SATA magic checkings (closes: #404310)
* Updated Swedish debconf template. Thanks to Daniel Nylander (closes:
  bug#398788).
* /etc/default/hddtemp: changed SYSLOG into RUN_SYSLOG and fixed the
  comments (closes: bug#401978).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2, or (at your option)
7
 
 * any later version.
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
8
13
 *
9
14
 * You should have received a copy of the GNU General Public License
10
 
 * (for example COPYING); if not, write to the Free
11
 
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
12
17
 */
13
18
 
14
19
// Include file generated by ./configure
148
153
 
149
154
int scsi_modesense(int device, unsigned char pagenum, unsigned char *buffer, int buffer_len) {
150
155
  unsigned char cdb[6];
 
156
  int ret;
151
157
  
152
158
  memset(cdb, 0, sizeof(cdb));
153
159
  cdb[0] = MODE_SENSE;
154
160
  cdb[2] = pagenum;
155
161
  cdb[4] = 0xff;
156
162
 
157
 
  return scsi_command(device, cdb, sizeof(cdb), buffer, buffer_len, SG_DXFER_FROM_DEV);
 
163
  ret = scsi_command(device, cdb, sizeof(cdb), buffer, buffer_len, SG_DXFER_FROM_DEV);
 
164
  if (ret == 0) {
 
165
    if ((buffer[3] + 5) > buffer[0]) /* response length too short */
 
166
      return -1;
 
167
  }
 
168
  return ret;
158
169
}
159
170
 
160
171
int scsi_modeselect(int device, char *buffer) {