The attr_info structure has a different size on x86_64, so we need to
copy the fields individually. This fixes optional package installation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34284 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
bf5b4ce27a
commit
1409c878f8
@ -1097,7 +1097,7 @@ yet, or I'd list a few)
|
|||||||
*/
|
*/
|
||||||
static int set_file_attrs( const char *name,
|
static int set_file_attrs( const char *name,
|
||||||
const unsigned char *attr_buff,
|
const unsigned char *attr_buff,
|
||||||
const off_t attr_size )
|
const off_t total_attr_size )
|
||||||
{
|
{
|
||||||
int retval = EOK;
|
int retval = EOK;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
@ -1105,7 +1105,7 @@ static int set_file_attrs( const char *name,
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
ptr = (unsigned char *)attr_buff;
|
ptr = (unsigned char *)attr_buff;
|
||||||
guard = ptr + attr_size;
|
guard = ptr + total_attr_size;
|
||||||
|
|
||||||
#ifdef HAIKU_USE_KERN_OPEN
|
#ifdef HAIKU_USE_KERN_OPEN
|
||||||
fd = _kern_open( -1, name, O_RDONLY | O_NOTRAVERSE, 0 );
|
fd = _kern_open( -1, name, O_RDONLY | O_NOTRAVERSE, 0 );
|
||||||
@ -1120,29 +1120,31 @@ static int set_file_attrs( const char *name,
|
|||||||
|
|
||||||
while( ptr < guard ) {
|
while( ptr < guard ) {
|
||||||
ssize_t wrote_bytes;
|
ssize_t wrote_bytes;
|
||||||
struct attr_info fa_info;
|
|
||||||
const char *attr_name;
|
const char *attr_name;
|
||||||
unsigned char *attr_data;
|
unsigned char *attr_data;
|
||||||
|
uint32 attr_type;
|
||||||
|
int64 attr_size;
|
||||||
|
|
||||||
attr_name = (char *)&(ptr[0]);
|
attr_name = (char *)&(ptr[0]);
|
||||||
ptr += strlen( attr_name ) + 1;
|
ptr += strlen( attr_name ) + 1;
|
||||||
|
|
||||||
/* The attr_info data is stored in big-endian format because the */
|
/* The attr_info data is stored in big-endian format because the */
|
||||||
/* PowerPC port was here first. */
|
/* PowerPC port was here first. */
|
||||||
memcpy( &fa_info, ptr, sizeof( struct attr_info ) );
|
memcpy( &attr_type, ptr, 4 ); ptr += 4;
|
||||||
fa_info.type = (uint32)B_BENDIAN_TO_HOST_INT32( fa_info.type );
|
memcpy( &attr_size, ptr, 8 ); ptr += 8;
|
||||||
fa_info.size = (off_t)B_BENDIAN_TO_HOST_INT64( fa_info.size );
|
|
||||||
ptr += sizeof( struct attr_info );
|
|
||||||
|
|
||||||
if( fa_info.size < 0LL ) {
|
attr_type = (uint32)B_BENDIAN_TO_HOST_INT32( attr_type );
|
||||||
|
attr_size = (off_t)B_BENDIAN_TO_HOST_INT64( attr_size );
|
||||||
|
|
||||||
|
if( attr_size < 0LL ) {
|
||||||
Info(slide, 0x201, ((char *)slide,
|
Info(slide, 0x201, ((char *)slide,
|
||||||
"warning: skipping attribute with invalid length (%Ld)\n",
|
"warning: skipping attribute with invalid length (%" B_PRIdOFF
|
||||||
fa_info.size));
|
")\n", attr_size));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
attr_data = ptr;
|
attr_data = ptr;
|
||||||
ptr += fa_info.size;
|
ptr += attr_size;
|
||||||
|
|
||||||
if( ptr > guard ) {
|
if( ptr > guard ) {
|
||||||
/* We've got a truncated attribute. */
|
/* We've got a truncated attribute. */
|
||||||
@ -1152,15 +1154,15 @@ static int set_file_attrs( const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wave the magic wand... this will swap Be-known types properly. */
|
/* Wave the magic wand... this will swap Be-known types properly. */
|
||||||
(void)swap_data( fa_info.type, attr_data, fa_info.size,
|
(void)swap_data( attr_type, attr_data, attr_size,
|
||||||
B_SWAP_BENDIAN_TO_HOST );
|
B_SWAP_BENDIAN_TO_HOST );
|
||||||
|
|
||||||
wrote_bytes = fs_write_attr( fd, attr_name, fa_info.type, 0,
|
wrote_bytes = fs_write_attr( fd, attr_name, attr_type, 0,
|
||||||
attr_data, fa_info.size );
|
attr_data, attr_size );
|
||||||
if( wrote_bytes != fa_info.size ) {
|
if( wrote_bytes != attr_size ) {
|
||||||
Info(slide, 0x201, ((char *)slide,
|
Info(slide, 0x201, ((char *)slide,
|
||||||
"warning: wrote %ld attribute bytes of %ld\n",
|
"warning: wrote %ld attribute bytes of %ld\n",
|
||||||
(unsigned long)wrote_bytes,(unsigned long)fa_info.size));
|
(unsigned long)wrote_bytes,(unsigned long)attr_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user