Do not use a random FW_CDEV_VERSION as our implemented ABI version

Since linux/firewire-cdev.h header file and libraw1394 sources are
distributed separately, it is wrong to fill in a constant from that
header into the FW_CDEV_IOC_GET_INFO ioctl as the ABI version which
libraw1394 supports.  This may not be forward compatible if an old
libraw1394 is compiled with a new kernel header and ran on top of a
kernel that implements new features that require a compatible
userland.

OK, the damage is already done in released versions of libraw1394.
Hence the FW_CDEV_VERSION of the kernel header file is not going to
be updated anymore in future kernel versions.  (Only the version
internally to firewire-core will be incremented further.)

But let's remove the buggy usage of FW_CDEV_VERSION nevertheless.
Developers of other firewire-cdev client programs might look at
libraw1394 sources.  The libraw1394 sources should not teach them
how to do it wrong.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
Stefan Richter 2010-06-20 18:03:33 +02:00
parent 8af54fd97d
commit a29d69af5d
1 changed files with 9 additions and 4 deletions

View File

@ -25,6 +25,11 @@
#include "fw.h" #include "fw.h"
#include "raw1394_private.h" #include "raw1394_private.h"
/*
* ABI version history is documented in linux/firewire-cdev.h.
*/
#define IMPLEMENTED_CDEV_ABI_VERSION 2
int int
fw_errcode_to_errno(raw1394_errcode_t errcode) fw_errcode_to_errno(raw1394_errcode_t errcode)
{ {
@ -150,7 +155,7 @@ scan_devices(fw_handle_t handle)
continue; continue;
memset(&get_info, 0, sizeof(get_info)); memset(&get_info, 0, sizeof(get_info));
memset(&reset, 0, sizeof(reset)); memset(&reset, 0, sizeof(reset));
get_info.version = FW_CDEV_VERSION; get_info.version = IMPLEMENTED_CDEV_ABI_VERSION;
get_info.rom = 0; get_info.rom = 0;
get_info.rom_length = 0; get_info.rom_length = 0;
get_info.bus_reset = ptr_to_u64(&reset); get_info.bus_reset = ptr_to_u64(&reset);
@ -355,7 +360,7 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec,
} }
} }
info.version = FW_CDEV_VERSION; info.version = IMPLEMENTED_CDEV_ABI_VERSION;
info.rom = 0; info.rom = 0;
info.rom_length = 0; info.rom_length = 0;
info.bus_reset = ptr_to_u64(&reset); info.bus_reset = ptr_to_u64(&reset);
@ -607,7 +612,7 @@ int fw_set_port(fw_handle_t handle, int port)
memset(&get_info, 0, sizeof(get_info)); memset(&get_info, 0, sizeof(get_info));
memset(&reset, 0, sizeof(reset)); memset(&reset, 0, sizeof(reset));
get_info.version = FW_CDEV_VERSION; get_info.version = IMPLEMENTED_CDEV_ABI_VERSION;
get_info.rom = 0; get_info.rom = 0;
get_info.rom_length = 0; get_info.rom_length = 0;
get_info.bus_reset = ptr_to_u64(&reset); get_info.bus_reset = ptr_to_u64(&reset);
@ -1378,7 +1383,7 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer,
} }
memset(&get_info, 0, sizeof(get_info)); memset(&get_info, 0, sizeof(get_info));
get_info.version = FW_CDEV_VERSION; get_info.version = IMPLEMENTED_CDEV_ABI_VERSION;
get_info.rom = ptr_to_u64(buffer); get_info.rom = ptr_to_u64(buffer);
get_info.rom_length = buffersize; get_info.rom_length = buffersize;
get_info.bus_reset = 0; get_info.bus_reset = 0;