Ticket #8484: patch-XASetOperation.c.diff

File patch-XASetOperation.c.diff, 1.2 KB (added by ulrich.kohlhase@…, 18 years ago)

XASetOperation.c diff

  • XASetOperation.c

    old new  
    1212#include <XAOperationInternal.h>
    1313#include <unistd.h>
    1414#include <stdio.h>
     15#include <errno.h>
    1516#include <fcntl.h>
    1617#include <string.h>
    1718#include <mach/mach.h>
    1819#include <sys/types.h>
    1920#include <sys/stat.h>
    20 
    21 #include "xattr.h"
     21#include <sys/xattr.h>
    2222
    2323typedef struct __XASetOperation
    2424{
     
    225225
    226226Boolean XASetOperationPerform(XAOperationRef opaqueRef, int fd, CFStringRef path)
    227227{
    228         Boolean bRet = 0x00;
     228        Boolean bRet = 0x01;
    229229       
    230230        XASetOperationRef operationRef = (XASetOperationRef)opaqueRef;
    231231       
     
    241241       
    242242        if(CFStringGetCString(operationRef->key, key, bSize, kCFStringEncodingUTF8))
    243243        {
    244                 size = fsetxattr(fd, key, (void *)bytes, size, position, options);
     244
     245                int fRet = fcntl(fd, F_NOCACHE, 0x01);
     246
     247                if(fRet < 0x00)
     248                        fprintf(stderr, "WARN: fcntl for key \"%s\" failed\n", key);
     249               
     250                int iRet = fsetxattr(fd, key, (void *)bytes, size, position, options);
     251               
     252                if(iRet < 0x00)
     253                {
     254                        if(errno != EEXIST || errno != ENOATTR)
     255                                fprintf(stderr, "ERROR: fsetxattr failed: %s\n", strerror(errno));
     256
     257                        bRet = 0x00;
     258                }
    245259        }
    246260       
    247261        free(key);