fix stat.h/attr.h related compilation errors (Jean-Pierre Andre)

N2009_11_14_FIXES
szaka 2010-01-15 00:31:50 +00:00
parent 2dfa3412da
commit 5807572640
8 changed files with 63 additions and 2 deletions

View File

@ -40,6 +40,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif

View File

@ -40,6 +40,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include "compat.h"
#include "attrib.h"

View File

@ -58,6 +58,8 @@
#include "misc.h"
#include "efs.h"
#ifdef HAVE_SETXATTR /* extended attributes interface required */
static ntfschar logged_utility_stream_name[] = {
const_cpu_to_le16('$'),
const_cpu_to_le16('E'),
@ -337,3 +339,5 @@ err_out:
ntfs_attr_put_search_ctx(ctx);
return (-1);
}
#endif /* HAVE_SETXATTR */

View File

@ -1197,6 +1197,8 @@ int ntfs_inode_badclus_bad(u64 mft_no, ATTR_RECORD *attr)
return ret;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* Get high precision NTFS times
*
@ -1344,3 +1346,5 @@ int ntfs_inode_set_times(const char *path __attribute__((unused)),
errno = EEXIST;
return (ret);
}
#endif /* HAVE_SETXATTR */

View File

@ -38,6 +38,9 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <time.h>
#include "compat.h"

View File

@ -914,6 +914,8 @@ BOOL ntfs_possible_symlink(ntfs_inode *ni)
return (possible);
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* Set the index for new reparse data
*
@ -951,6 +953,8 @@ static int set_reparse_index(ntfs_inode *ni, ntfs_index_context *xr,
return (ntfs_ie_add(xr,(INDEX_ENTRY*)&indx));
}
#endif /* HAVE_SETXATTR */
/*
* Remove a reparse data index entry if attribute present
*
@ -1015,6 +1019,8 @@ static ntfs_index_context *open_reparse_index(ntfs_volume *vol)
return (xr);
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* Update the reparse data and index
*
@ -1079,6 +1085,8 @@ static int update_reparse_data(ntfs_inode *ni, ntfs_index_context *xr,
return (res);
}
#endif /* HAVE_SETXATTR */
/*
* Delete a reparse index entry
*
@ -1116,6 +1124,8 @@ int ntfs_delete_reparse_index(ntfs_inode *ni)
return (res);
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* Get the ntfs reparse data into an extended attribute
*
@ -1294,3 +1304,5 @@ int ntfs_remove_ntfs_reparse_data(const char *path __attribute__((unused)),
}
return (res ? -1 : 0);
}
#endif /* HAVE_SETXATTR */

View File

@ -41,6 +41,9 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#endif
@ -2893,6 +2896,8 @@ BOOL ntfs_allowed_as_owner(struct SECURITY_CONTEXT *scx,
return (allowed);
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
#if POSIXACLS
/*
@ -3074,6 +3079,8 @@ int ntfs_set_ntfs_acl(struct SECURITY_CONTEXT *scx,
return (res ? -1 : 0);
}
#endif /* HAVE_SETXATTR */
/*
* Set new permissions to a file
* Checks user mapping has been defined before request for setting
@ -3988,6 +3995,8 @@ int ntfs_build_mapping(struct SECURITY_CONTEXT *scx, const char *usermap_path)
return (!scx->mapping[MAPUSERS] || link_group_members(scx));
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* Get the ntfs attribute into an extended attribute
* The attribute is returned according to cpu endianness
@ -4073,6 +4082,8 @@ int ntfs_set_ntfs_attrib(const char *path __attribute__((unused)),
return (res ? -1 : 0);
}
#endif /* HAVE_SETXATTR */
/*
* Open $Secure once for all
* returns zero if it succeeds

View File

@ -151,7 +151,9 @@ typedef struct {
BOOL no_detach;
BOOL blkdev;
BOOL mounted;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
BOOL efs_raw;
#endif /* HAVE_SETXATTR */
struct fuse_chan *fc;
BOOL inherit;
unsigned int secure_flags;
@ -593,6 +595,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
/* Regular or Interix (INTX) file. */
stbuf->st_mode = S_IFREG;
stbuf->st_size = ni->data_size;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/*
* return data size rounded to next 512 byte boundary for
* encrypted files to include padding required for decryption
@ -600,7 +603,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
*/
if (ctx->efs_raw && ni->flags & FILE_ATTR_ENCRYPTED)
stbuf->st_size = ((ni->data_size + 511) & ~511) + 2;
#endif /* HAVE_SETXATTR */
/*
* Temporary fix to make ActiveSync work via Samba 3.0.
* See more on the ntfs-3g-devel list.
@ -629,12 +632,14 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
if (na->data_size == 1)
stbuf->st_mode = S_IFSOCK;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* encrypted named stream */
/* round size up to next 512 byte boundary */
if (ctx->efs_raw && stream_name_len &&
(na->data_flags & ATTR_IS_ENCRYPTED) &&
NAttrNonResident(na))
stbuf->st_size = ((na->data_size+511) & ~511)+2;
#endif /* HAVE_SETXATTR */
/*
* Check whether it's Interix symbolic link, block or
* character device.
@ -969,11 +974,13 @@ static int ntfs_fuse_open(const char *org_path,
/* mark a future need to compress the last chunk */
if (na->data_flags & ATTR_COMPRESSION_MASK)
fi->fh |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (ctx->efs_raw
&& !(na->data_flags & ATTR_IS_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
}
ntfs_attr_close(na);
} else
@ -1015,12 +1022,14 @@ static int ntfs_fuse_read(const char *org_path, char *buf, size_t size,
res = -errno;
goto exit;
}
/* limit reads at next 512 byte boundary for encrypted attributes */
max_read = na->data_size;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* limit reads at next 512 byte boundary for encrypted attributes */
if (ctx->efs_raw && (na->data_flags & ATTR_IS_ENCRYPTED) &&
NAttrNonResident(na)) {
max_read = ((na->data_size+511) & ~511) + 2;
}
#endif /* HAVE_SETXATTR */
if (offset + (off_t)size > max_read) {
if (max_read < offset)
goto ok;
@ -1137,8 +1146,10 @@ static int ntfs_fuse_release(const char *org_path,
res = 0;
if (fi->fh & CLOSE_COMPRESSED)
res = ntfs_attr_pclose(na);
#ifdef HAVE_SETXATTR /* extended attributes interface required */
if (fi->fh & CLOSE_ENCRYPTED)
res = ntfs_efs_fixup_attribute(NULL, na);
#endif /* HAVE_SETXATTR */
exit:
if (na)
ntfs_attr_close(na);
@ -1498,11 +1509,13 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
if (fi && (ni->flags & FILE_ATTR_COMPRESSED)) {
fi->fh |= CLOSE_COMPRESSED;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (fi
&& ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
NInoSetDirty(ni);
/*
* closing ni will necessitate to open dir_ni to
@ -1568,10 +1581,12 @@ static int ntfs_fuse_create_stream(const char *path,
/* mark a future need to compress the last block */
if (ni->flags & FILE_ATTR_COMPRESSED)
fi->fh |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
}
if (ntfs_inode_close(ni))
@ -3321,7 +3336,9 @@ static char *parse_mount_options(const char *orig_opts)
int want_permissions = 0;
ctx->secure_flags = 0;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
ctx->efs_raw = FALSE;
#endif /* HAVE_SETXATTR */
options = strdup(orig_opts ? orig_opts : "");
if (!options) {
ntfs_log_perror("%s: strdup failed", EXEC_NAME);
@ -3504,10 +3521,12 @@ static char *parse_mount_options(const char *orig_opts)
"'usermapping' option.\n");
goto err_exit;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
} else if (!strcmp(opt, "efs_raw")) {
if (bogus_option_value(val, "efs_raw"))
goto err_exit;
ctx->efs_raw = TRUE;
#endif /* HAVE_SETXATTR */
} else { /* Probably FUSE option. */
if (strappend(&ret, opt))
goto err_exit;
@ -3962,7 +3981,9 @@ int main(int argc, char *argv[])
ctx->security.vol = ctx->vol;
ctx->vol->secure_flags = ctx->secure_flags;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
ctx->vol->efs_raw = ctx->efs_raw;
#endif /* HAVE_SETXATTR */
/* JPA open $Secure, (whatever NTFS version !) */
/* to initialize security data */
if (ntfs_open_secure(ctx->vol) && (ctx->vol->major_ver >= 3))