vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / generic / scsi_periph / sync.cpp
bloba8f89571091a148d97b97aca76e915d5def030d8
1 /*
2 * Copyright 2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Bruno Albuquerque, bga@bug-br.org.br
8 * Copyright 2004-2006 yellowTAB GMbH. This file is
9 * based on work I did for ZETA while employed by
10 * yellowTAB and is used under permission.
14 #include "scsi_periph_int.h"
16 #include <scsi_cmds.h>
18 #include <string.h>
21 err_res
22 periph_synchronize_cache(scsi_periph_device_info *device, scsi_ccb *request)
24 scsi_cmd_sync_cache* cmd = (scsi_cmd_sync_cache*)request->cdb;
26 request->flags = SCSI_DIR_NONE;
28 request->data = NULL;
29 request->sg_list = NULL;
30 request->data_length = 0;
31 request->timeout = device->std_timeout;
32 request->sort = -1;
34 memset(cmd, 0, sizeof(*cmd));
36 cmd->opcode = SCSI_OP_SYNCHRONIZE_CACHE;
37 cmd->immediately = 0;
39 // TODO: Maybe we will actually want to set this one day...
40 cmd->block_count = 0;
42 request->cdb_length = sizeof(*cmd);
44 device->scsi->sync_io(request);
46 return periph_check_error(device, request);