io.c (32cc71def9e3885f9527af713e6d8dc7521ddc08) | io.c (353a5d84b25c335b259f37c4f43dad96e6d60ba8) |
---|---|
1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 1086 unchanged lines hidden (view full) --- 1095 offset += bytes; 1096 } 1097} 1098 1099/* See bdrv_pwrite() for the return codes */ 1100int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, 1101 BdrvRequestFlags flags) 1102{ | 1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 1086 unchanged lines hidden (view full) --- 1095 offset += bytes; 1096 } 1097} 1098 1099/* See bdrv_pwrite() for the return codes */ 1100int bdrv_pread(BdrvChild *child, int64_t offset, int64_t bytes, void *buf, 1101 BdrvRequestFlags flags) 1102{ |
1103 int ret; | |
1104 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); 1105 IO_CODE(); 1106 1107 if (bytes < 0) { 1108 return -EINVAL; 1109 } 1110 | 1103 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); 1104 IO_CODE(); 1105 1106 if (bytes < 0) { 1107 return -EINVAL; 1108 } 1109 |
1111 ret = bdrv_preadv(child, offset, bytes, &qiov, flags); 1112 1113 return ret < 0 ? ret : bytes; | 1110 return bdrv_preadv(child, offset, bytes, &qiov, flags); |
1114} 1115 1116/* Return no. of bytes on success or < 0 on error. Important errors are: 1117 -EIO generic I/O error (may happen for all errors) 1118 -ENOMEDIUM No media inserted. 1119 -EINVAL Invalid offset or number of bytes 1120 -EACCES Trying to write a read-only device 1121*/ 1122int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, 1123 const void *buf, BdrvRequestFlags flags) 1124{ | 1111} 1112 1113/* Return no. of bytes on success or < 0 on error. Important errors are: 1114 -EIO generic I/O error (may happen for all errors) 1115 -ENOMEDIUM No media inserted. 1116 -EINVAL Invalid offset or number of bytes 1117 -EACCES Trying to write a read-only device 1118*/ 1119int bdrv_pwrite(BdrvChild *child, int64_t offset, int64_t bytes, 1120 const void *buf, BdrvRequestFlags flags) 1121{ |
1125 int ret; | |
1126 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); 1127 IO_CODE(); 1128 1129 if (bytes < 0) { 1130 return -EINVAL; 1131 } 1132 | 1122 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); 1123 IO_CODE(); 1124 1125 if (bytes < 0) { 1126 return -EINVAL; 1127 } 1128 |
1133 ret = bdrv_pwritev(child, offset, bytes, &qiov, flags); 1134 1135 return ret < 0 ? ret : bytes; | 1129 return bdrv_pwritev(child, offset, bytes, &qiov, flags); |
1136} 1137 1138/* 1139 * Writes to the file and ensures that no writes are reordered across this 1140 * request (acts as a barrier) 1141 * 1142 * Returns 0 on success, -errno in error cases. 1143 */ --- 2572 unchanged lines hidden --- | 1130} 1131 1132/* 1133 * Writes to the file and ensures that no writes are reordered across this 1134 * request (acts as a barrier) 1135 * 1136 * Returns 0 on success, -errno in error cases. 1137 */ --- 2572 unchanged lines hidden --- |