* Add a missing result assign that would cause the synchronize ioctl to always

return an error.
* Properly use the name length instead of a hardcoded buffer size when composing
  the name of the raw device and ensure proper termination.
* Case new ioctls for Haiku as the target platform. Indeed this driver works
  fine on BeOS even though it was written natively for Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33240 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2009-09-23 02:16:47 +00:00
parent 1393394ba6
commit 8b6349fd32

View File

@ -909,15 +909,17 @@ usb_disk_open(const char *name, uint32 flags, void **cookie)
return B_NAME_NOT_FOUND;
int32 lastPart = 0;
for (int32 i = strlen(name) - 1; i >= 0; i--) {
size_t nameLength = strlen(name);
for (int32 i = nameLength - 1; i >= 0; i--) {
if (name[i] == '/') {
lastPart = i;
break;
}
}
char rawName[32];
strlcpy(rawName, name, lastPart + 2);
char rawName[nameLength + 4];
strncpy(rawName, name, lastPart + 1);
rawName[lastPart + 1] = 0;
strcat(rawName, "raw");
TRACE("opening raw device %s for %s\n", rawName, name);
@ -1027,7 +1029,7 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
case B_FLUSH_DRIVE_CACHE:
TRACE("B_FLUSH_DRIVE_CACHE\n");
usb_disk_synchronize(lun, true);
result = usb_disk_synchronize(lun, true);
break;
case B_EJECT_DEVICE:
@ -1040,6 +1042,7 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
NULL, NULL, false);
break;
#if HAIKU_TARGET_PLATFORM_HAIKU
case B_GET_ICON:
// We don't support this legacy ioctl anymore, but the two other
// icon ioctls below instead.
@ -1075,6 +1078,7 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
result = user_memcpy(buffer, &iconData, sizeof(device_icon));
break;
}
#endif
default:
TRACE_ALWAYS("unhandled ioctl %ld\n", op);