Merged changes r32805, r32806, r32807, r32812, r32813 and r32814 from trunk.
git-svn-id: file:///srv/svn/repos/haiku/haiku/branches/releases/r1alpha1@32861 a95241bf-73f2-0310-859d-f6bbb57e9c96
Diff
headers/os/device/CAM.h | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
src/kits/storage/Volume.cpp | 8 ++++++--
src/system/kernel/signal.cpp | 13 +++++--------
src/system/kernel/debug/debug.cpp | 5 +++--
src/system/kernel/fs/rootfs.cpp | 13 ++++++++++---
src/system/libroot/posix/utime.c | 22 ++++++++++++++--------
src/system/libroot/posix/sys/utimes.c | 44 +++++++++++++++++++++++++++++++++++++-------
7 files changed, 180 insertions(+), 155 deletions(-)
@@ -1,27 +1,20 @@
/* ++++++++++
CAM.h
Copyright (c) 1996-98 by Be Incorporated. All Rights Reserved.
Definitions for the SCSI Common Access Method as implemented in the Be OS.
See also "Draft Proposed American National Standard, SCSI-2 Common
Access Method Transport and SCSI Interface Module", Revision 12,
ANSI refernce number X3.232-199x.
This file consists of the definitions for the fictional "UNIVOS"
operating system described in the standard. The file is mostly
the same text as the standard, with Be-provided additions as needed.
+++++ */
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
*
* Definitions for the SCSI Common Access Method as implemented in Haiku.
*
* See also "Draft Proposed American National Standard, SCSI-2 Common
* Access Method Transport and SCSI Interface Module", Revision 12,
* ANSI refernce number X3.232-199x.
*
*/
#ifndef _CAM_H
#define _CAM_H
#include <bus_manager.h>
/* ---
Be-provided additions to the standard include file.
--- */
#include <sys/types.h>
@@ -41,22 +34,19 @@
typedef unsigned short U16;
#endif
typedef struct {
uint32 serial;
uint32 micros;
uint32 bytes;
uchar path;
uchar target;
uchar sgcount;
uchar scsi_op;
uint32 serial;
uint32 micros;
uint32 bytes;
uchar path;
uchar target;
uchar sgcount;
uchar scsi_op;
} cam_iostat;
/* -----
The rest of this file contains the definitions and data structures for
the CAM Subsystem interface. The contents of this file should match the
data structures and constants that are specified in the CAM document
----- */
@@ -91,8 +81,6 @@
#define XPT_FUNC 0x7F /* TEMPLATE */
#define XPT_VUNIQUE 0x80 /* All the rest are vendor unique commands */
#define IOCDBLEN 12 /* Space for the CDB bytes/pointer */
@@ -100,8 +88,8 @@
#define SIM_ID 16 /* ASCII string len for SIM ID */
#define HBA_ID 16 /* ASCII string len for HBA ID */
#define BE_SIM_CCB_SIZE 1536 /* we want to allocate 1.5k chunks */
#define BE_SIM_SCSIIO_SIZE 88 /* sizeof(CAM_CCB_SCSIIO) - SIM_PRIV */
#define BE_SIM_CCB_SIZE 1536 /* we want to allocate 1.5k chunks */
#define BE_SIM_SCSIIO_SIZE 88 /* sizeof(CAM_CCB_SCSIIO) - SIM_PRIV */
#define SIM_PRIV (BE_SIM_CCB_SIZE - BE_SIM_SCSIIO_SIZE) /* Length of SIM private data area */
/* SIM_PRIV (sim private data area) Terms and Conditions:
@@ -124,15 +112,15 @@
typedef struct ccb_header
{
uint32 phys_addr;
uint16 cam_ccb_len;
uchar cam_func_code;
uchar cam_status;
uchar cam_hrsvd0;
uchar cam_path_id;
uchar cam_target_id;
uchar cam_target_lun;
uint32 cam_flags;
uint32 phys_addr;
uint16 cam_ccb_len;
uchar cam_func_code;
uchar cam_status;
uchar cam_hrsvd0;
uchar cam_path_id;
uchar cam_target_id;
uchar cam_target_lun;
uint32 cam_flags;
} CCB_HEADER;
@@ -140,16 +128,16 @@
typedef union cdb_un
{
uchar *cam_cdb_ptr;
uchar cam_cdb_bytes[ IOCDBLEN ];
uchar* cam_cdb_ptr;
uchar cam_cdb_bytes[IOCDBLEN];
} CDB_UN;
typedef struct ccb_getdev
{
CCB_HEADER cam_ch;
char *cam_inq_data;
uchar cam_pd_type;
CCB_HEADER cam_ch;
char* cam_inq_data;
uchar cam_pd_type;
} CCB_GETDEV;
@@ -161,52 +149,52 @@
uchar cam_target_sprt;
uchar cam_hba_misc;
uint16 cam_hba_eng_cnt;
uchar cam_vuhba_flags[ VUHBA ];
uchar cam_vuhba_flags[VUHBA];
uint32 cam_sim_priv;
uint32 cam_async_flags;
uchar cam_hpath_id;
uchar cam_initiator_id;
uchar cam_prsvd0;
uchar cam_prsvd1;
char cam_sim_vid[ SIM_ID ];
char cam_hba_vid[ HBA_ID ];
uchar *cam_osd_usage;
char cam_sim_vid[SIM_ID];
char cam_hba_vid[HBA_ID];
uchar* cam_osd_usage;
} CCB_PATHINQ;
typedef struct ccb_relsim
{
CCB_HEADER cam_ch;
CCB_HEADER cam_ch;
} CCB_RELSIM;
typedef struct ccb_scsiio
{
CCB_HEADER cam_ch;
uchar *cam_pdrv_ptr;
CCB_HEADER *cam_next_ccb;
uchar *cam_req_map;
void (*cam_cbfcnp)(struct ccb_scsiio *);
uchar *cam_data_ptr;
uint32 cam_dxfer_len;
uchar *cam_sense_ptr;
uchar cam_sense_len;
uchar cam_cdb_len;
uint16 cam_sglist_cnt;
uint32 cam_sort;
uchar cam_scsi_status;
uchar cam_sense_resid;
uchar cam_osd_rsvd1[2];
int32 cam_resid;
CDB_UN cam_cdb_io;
uint32 cam_timeout;
uchar *cam_msg_ptr;
uint16 cam_msgb_len;
uint16 cam_vu_flags;
uchar cam_tag_action;
uchar cam_iorsvd0[3];
uchar cam_sim_priv[ SIM_PRIV ];
CCB_HEADER cam_ch;
uchar* cam_pdrv_ptr;
CCB_HEADER* cam_next_ccb;
uchar* cam_req_map;
void (*cam_cbfcnp)(struct ccb_scsiio*);
uchar* cam_data_ptr;
uint32 cam_dxfer_len;
uchar* cam_sense_ptr;
uchar cam_sense_len;
uchar cam_cdb_len;
uint16 cam_sglist_cnt;
uint32 cam_sort;
uchar cam_scsi_status;
uchar cam_sense_resid;
uchar cam_osd_rsvd1[2];
int32 cam_resid;
CDB_UN cam_cdb_io;
uint32 cam_timeout;
uchar* cam_msg_ptr;
uint16 cam_msgb_len;
uint16 cam_vu_flags;
uchar cam_tag_action;
uchar cam_iorsvd0[3];
uchar cam_sim_priv[SIM_PRIV];
} CCB_SCSIIO;
@@ -215,15 +203,15 @@
CCB_HEADER cam_ch;
uint32 cam_async_flags;
void (*cam_async_func)();
uchar *pdrv_buf;
uchar* pdrv_buf;
uchar pdrv_buf_len;
} CCB_SETASYNC;
typedef struct ccb_setdev
{
CCB_HEADER cam_ch;
uchar cam_dev_type;
CCB_HEADER cam_ch;
uchar cam_dev_type;
} CCB_SETDEV;
@@ -232,7 +220,7 @@
typedef struct ccb_abort
{
CCB_HEADER cam_ch;
CCB_HEADER *cam_abort_ch;
CCB_HEADER* cam_abort_ch;
} CCB_ABORT;
@@ -251,7 +239,7 @@
typedef struct ccb_termio
{
CCB_HEADER cam_ch;
CCB_HEADER *cam_termio_ch;
CCB_HEADER* cam_termio_ch;
} CCB_TERMIO;
@@ -262,7 +250,7 @@
CCB_HEADER cam_ch;
uint16 cam_grp6_len;
uint16 cam_grp7_len;
uchar *cam_ccb_listptr;
uchar* cam_ccb_listptr;
uint16 cam_ccb_listcnt;
} CCB_EN_LUN;
@@ -272,20 +260,20 @@
CCB_HEADER cam_ch;
uint16 cam_grp6_length;
uint16 cam_grp7_length;
uchar *cam_immed_notify_list;
uchar* cam_immed_notify_list;
uint32 cam_immed_notify_cnt;
uchar *cam_accept_targ_list;
uchar* cam_accept_targ_list;
uint32 cam_accept_targ_cnt;
uchar cam_sim_priv[ SIM_PRIV ];
uchar cam_sim_priv[SIM_PRIV];
} CCB_ENABLE_LUN;
typedef struct ccb_immed_notify
{
CCB_HEADER cam_ch;
uchar *cam_pdrv_ptr;
uchar* cam_pdrv_ptr;
void (*cam_cbfnot)();
uchar *cam_sense_ptr;
uchar* cam_sense_ptr;
uchar cam_sense_len;
uchar cam_init_id;
uint16 cam_seq_id;
@@ -306,13 +294,13 @@
typedef struct ccb_accept_targ
{
CCB_HEADER cam_ch;
uchar *cam_pdrv_ptr;
CCB_HEADER *cam_next_ccb;
uchar *cam_req_map;
uchar* cam_pdrv_ptr;
CCB_HEADER* cam_next_ccb;
uchar* cam_req_map;
void (*cam_cbfcnot)();
uchar *cam_data_ptr;
uchar* cam_data_ptr;
uint32 cam_dxfer_len;
uchar *cam_sense_ptr;
uchar* cam_sense_ptr;
uchar cam_sense_len;
uchar cam_cdb_len;
uint16 cam_sglist_cnt;
@@ -323,14 +311,14 @@
int32 cam_resid;
CDB_UN cam_cdb_io;
uint32 cam_timeout;
uchar *cam_msg_ptr;
uchar* cam_msg_ptr;
uint16 cam_msgb_len;
uint16 cam_vu_flags;
uchar cam_tag_action;
uchar cam_tag_id;
uchar cam_initiator_id;
uchar cam_iorsvd0[1];
uchar cam_sim_priv[ SIM_PRIV ];
uchar cam_sim_priv[SIM_PRIV];
} CCB_ACCEPT_TARG;
@@ -350,13 +338,13 @@
typedef struct ccb_eng_exec
{
CCB_HEADER cam_ch;
uchar *cam_pdrv_ptr;
uchar* cam_pdrv_ptr;
uint32 cam_engrsvd0;
uchar *cam_req_map;
uchar* cam_req_map;
void (*cam_cbfcnp)();
uchar *cam_data_ptr;
uchar* cam_data_ptr;
uint32 cam_dxfer_len;
uchar *cam_engdata_ptr;
uchar* cam_engdata_ptr;
uchar cam_engrsvd1;
uchar cam_engrsvd2;
uint16 cam_sglist_cnt;
@@ -370,7 +358,7 @@
uint16 cam_vu_flags;
uchar cam_engrsvd5;
uchar cam_engrsvd6[3];
uchar cam_sim_priv[ SIM_PRIV ];
uchar cam_sim_priv[SIM_PRIV];
} CCB_ENG_EXEC;
/* The sim_module_info definition is used to define the entry points for
@@ -382,14 +370,14 @@
typedef struct sim_module_info sim_module_info;
struct sim_module_info {
module_info minfo;
module_info minfo;
};
typedef struct CAM_SIM_ENTRY CAM_SIM_ENTRY;
struct CAM_SIM_ENTRY {
status_t (*sim_init)();
int32 (*sim_action)();
status_t (*sim_init)();
int32 (*sim_action)();
};
@@ -544,7 +532,7 @@
typedef struct sg_elem
{
uchar *cam_sg_address;
uchar* cam_sg_address;
uint32 cam_sg_count;
} SG_ELEM;
@@ -588,11 +576,11 @@
typedef struct async_info
{
struct async_info *cam_async_next;
struct async_info* cam_async_next;
uint32 cam_event_enable;
void (*cam_async_func)();
uint32 cam_async_blen;
uchar *cam_async_ptr;
uchar* cam_async_ptr;
} ASYNC_INFO;
/* The CAM EDT table contains the device information for all the
@@ -603,9 +591,9 @@
typedef struct cam_edt_entry
{
int32 cam_tlun_found;
ASYNC_INFO *cam_ainfo;
ASYNC_INFO* cam_ainfo;
uint32 cam_owner_tag;
char cam_inq_data[ INQLEN ];
char cam_inq_data[INQLEN];
} CAM_EDT_ENTRY;
@@ -628,15 +616,15 @@
typedef struct ccb_extended_pathinq
{
CCB_PATHINQ cam_path;
char cam_sim_version [ VERS ];
char cam_hba_version [ VERS ];
char cam_controller_family [ FAM_ID ];
char cam_controller_type [ TYPE_ID ];
char cam_sim_version[VERS];
char cam_hba_version[VERS];
char cam_controller_family[FAM_ID];
char cam_controller_type[TYPE_ID];
} CCB_EXTENDED_PATHINQ;
/* ---
Vendor unique flags supported by Be OS (cam_vu_flags)
Vendor unique flags supported by Haiku (cam_vu_flags)
--- */
enum {
@@ -655,9 +643,9 @@
struct cam_for_driver_module_info {
bus_manager_info minfo;
CCB_HEADER * (*xpt_ccb_alloc)(void);
void (*xpt_ccb_free)(void *ccb);
long (*xpt_action)(CCB_HEADER *ccbh);
CCB_HEADER* (*xpt_ccb_alloc)(void);
void (*xpt_ccb_free)(void* ccb);
long (*xpt_action)(CCB_HEADER* ccbh);
};
#define B_CAM_FOR_DRIVER_MODULE_NAME "bus_managers/scsi/driver/v1"
@@ -670,8 +658,8 @@
struct cam_for_sim_module_info {
bus_manager_info minfo;
long (*xpt_bus_register) (CAM_SIM_ENTRY *sim);
long (*xpt_bus_deregister) (long path);
long (*xpt_bus_register)(CAM_SIM_ENTRY* sim);
long (*xpt_bus_deregister)(long path);
};
#define B_CAM_FOR_SIM_MODULE_NAME "bus_managers/scsi/sim/v1"
@@ -292,14 +292,18 @@
FS_WRITE_FSINFO_NAME);
if (error != B_OK)
return error;
BPath entryPath;
BEntry entry;
BEntry traversedEntry;
@@ -313,7 +317,7 @@
&& traversedEntry.GetNodeRef(&entryNodeRef) == B_OK
&& entryNodeRef.device == fDevice
&& entryNodeRef.node == oldInfo.root) {
traversedEntry.Rename(name, false);
entry.Rename(name, false);
}
return error;
}
@@ -59,7 +59,7 @@
static status_t deliver_signal(struct thread *thread, uint signal,
uint32 flags, bool& reschedule);
uint32 flags, bool &reschedule);
@@ -489,7 +489,7 @@
*/
static status_t
deliver_signal(struct thread *thread, uint signal, uint32 flags,
bool& reschedule)
bool &reschedule)
{
if (flags & B_CHECK_PERMISSION) {
@@ -581,10 +581,8 @@
GRAB_THREAD_LOCK();
thread = thread_get_thread_struct_locked(id);
if (thread != NULL) {
status = deliver_signal(thread, signal, flags,
reschedule);
}
if (thread != NULL)
status = deliver_signal(thread, signal, flags, reschedule);
} else {
@@ -617,8 +615,7 @@
if (thread != NULL) {
status = deliver_signal(thread, signal, flags,
reschedule);
status = deliver_signal(thread, signal, flags, reschedule);
}
RELEASE_THREAD_LOCK();
@@ -1297,7 +1297,6 @@
debug_variables_init();
frame_buffer_console_init(args);
arch_debug_console_init_settings(args);
tracing_init();
@@ -1319,7 +1318,9 @@
syslog_init(args);
return arch_debug_init(args);
arch_debug_init(args);
tracing_init();
return B_OK;
}
@@ -930,9 +930,16 @@
struct rootfs_vnode* fromDirectory = (rootfs_vnode*)_fromDir->private_node;
struct rootfs_vnode* toDirectory = (rootfs_vnode*)_toDir->private_node;
TRACE(("rootfs_rename: from %p (0x%Lx), fromName '%s', to %p (0x%Lx), "
"toName '%s'\n", fromDirectory, fromDirectory->id, fromName, toDirectory,
toDirectory->id, toName));
TRACE(("rootfs_rename: from %p (0x%Lx, %s), fromName '%s', to %p "
"(0x%Lx, %s), toName '%s'\n", fromDirectory, fromDirectory->id,
fromDirectory->name != NULL ? fromDirectory->name : "NULL",
fromName, toDirectory, toDirectory->id,
toDirectory->name != NULL ? toDirectory->name : "NULL",
toName));
if (fromDirectory->id == 1 && strcmp(fromName, "boot") == 0)
return EPERM;
MutexLocker _(&fs->lock);
@@ -1,14 +1,16 @@
/*
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <NodeMonitor.h>
#include <utime.h>
#include <time.h>
#include <errno.h>
#include <time.h>
#include <NodeMonitor.h>
#include <syscalls.h>
@@ -27,10 +29,14 @@
status_t status;
if (times != NULL) {
stat.st_atime = times->actime;
stat.st_mtime = times->modtime;
} else
stat.st_atime = stat.st_mtime = time(NULL);
stat.st_atim.tv_sec = times->actime;
stat.st_mtim.tv_sec = times->modtime;
stat.st_atim.tv_nsec = stat.st_mtim.tv_nsec = 0;
} else {
bigtime_t now = real_time_clock_usecs();
stat.st_atim.tv_sec = stat.st_mtim.tv_sec = now / 1000000;
stat.st_atim.tv_nsec = stat.st_mtim.tv_nsec = (now % 1000000) * 1000;
}
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
B_STAT_MODIFICATION_TIME | B_STAT_ACCESS_TIME);
@@ -1,25 +1,47 @@
/*
* Copyright 2006, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2006-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <sys/time.h>
#include <utime.h>
#include <errno.h>
#include <NodeMonitor.h>
#include <syscalls.h>
#define RETURN_AND_SET_ERRNO(err) \
if (err < 0) { \
errno = err; \
return -1; \
} \
return err;
int
utimes(const char *file, const struct timeval times[2])
utimes(const char* path, const struct timeval times[2])
{
struct utimbuf buffer, *timeBuffer;
struct stat stat;
status_t status;
if (times != NULL) {
timeBuffer = &buffer;
buffer.actime = times[0].tv_sec + times[0].tv_usec / 1000000LL;
buffer.modtime = times[1].tv_sec + times[1].tv_usec / 1000000LL;
} else
timeBuffer = NULL;
return utime(file, timeBuffer);
stat.st_atim.tv_sec = times[0].tv_sec;
stat.st_atim.tv_nsec = times[0].tv_usec * 1000;
stat.st_mtim.tv_sec = times[1].tv_sec;
stat.st_mtim.tv_nsec = times[1].tv_usec * 1000;
} else {
bigtime_t now = real_time_clock_usecs();
stat.st_atim.tv_sec = stat.st_mtim.tv_sec = now / 1000000;
stat.st_atim.tv_nsec = stat.st_mtim.tv_nsec = (now % 1000000) * 1000;
}
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
B_STAT_MODIFICATION_TIME | B_STAT_ACCESS_TIME);
RETURN_AND_SET_ERRNO(status);
}