add_command(&attr_remove_cmd);
}
-static unsigned char *
+static char *
get_buf_from_file(
const char *fname,
size_t bufsize,
int *namelen)
{
FILE *fp;
- unsigned char *buf;
+ char *buf;
size_t sz;
buf = malloc(bufsize + 1);
return 0;
}
- args.name = (const unsigned char *)argv[optind];
+ args.name = argv[optind];
if (!args.name) {
dbprintf(_("invalid name\n"));
return 0;
return 0;
}
- args.name = (const unsigned char *)argv[optind];
+ args.name = argv[optind];
if (!args.name) {
dbprintf(_("invalid name\n"));
return 0;
error = -libxfs_attr_set(&args, XFS_ATTRUPDATE_REMOVE, false);
if (error) {
dbprintf(_("failed to remove attr %s from inode %llu: %s\n"),
- (unsigned char *)args.name,
- (unsigned long long)iocur_top->ino,
+ args.name, (unsigned long long)iocur_top->ino,
strerror(error));
goto out;
}
return 0;
}
- args.name = (const unsigned char *)argv[optind];
+ args.name = argv[optind];
if (!args.name) {
dbprintf(_("invalid name\n"));
return 0;
struct xfs_trans *tp,
struct xfs_inode *ip,
unsigned int attr_flags,
- const unsigned char *name,
+ const char *name,
unsigned int namelen,
const void *value,
unsigned int valuelen,
tag_err += be16_to_cpu(*tagp) != (char *)dep - (char *)data;
addr = xfs_dir2_db_off_to_dataptr(mp->m_dir_geo, db,
(char *)dep - (char *)data);
- xname.name = dep->name;
+ xname.name = (char *)dep->name;
xname.len = dep->namelen;
dir_hash_add(libxfs_dir2_hashname(mp, &xname), addr);
ptr += libxfs_dir2_data_entsize(mp, dep->namelen);
for (c = optind; c < argc; c++) {
struct xfs_name xname = {
- .name = (uint8_t *)argv[c],
+ .name = argv[c],
.len = strlen(argv[c]),
};
int ret;
do {
- ret = find_alternate(namelen, (uint8_t *)name, seq++);
+ ret = find_alternate(namelen, name, seq++);
} while (ret == 0);
if (ret < 0)
return EEXIST;
int fd)
{
struct xfs_name dname = {
- .name = (uint8_t *)name,
+ .name = name,
.len = namelen,
};
char direntname[MAXNAMELEN + 1];
return error;
}
- dname.name = (uint8_t *)direntname;
+ dname.name = direntname;
for (i = 0; i < nr; i++) {
strncpy(direntname, name, MAXNAMELEN);
- obfuscate_name(old_hash, namelen, (uint8_t *)direntname, true);
+ obfuscate_name(old_hash, namelen, direntname, true);
ASSERT(old_hash == libxfs_dir2_hashname(mp, &dname));
if (fd >= 0) {
unsigned long i;
int error = 0;
- old_hash = libxfs_attr_hashname((uint8_t *)name, namelen);
+ old_hash = libxfs_attr_hashname(name, namelen);
if (fd >= 0) {
/*
for (i = 0; i < nr; i++) {
snprintf(xattrname, MAXNAMELEN + 5, "user.%s", name);
- obfuscate_name(old_hash, namelen, (uint8_t *)xattrname + 5,
+ obfuscate_name(old_hash, namelen, xattrname + 5,
false);
ASSERT(old_hash == libxfs_attr_hashname(
- (uint8_t *)xattrname + 5, namelen));
+ xattrname + 5, namelen));
if (fd >= 0) {
error = fsetxattr(fd, xattrname, "1", 1, 0);
struct name_ent *next;
xfs_dahash_t hash;
int namelen;
- unsigned char name[1];
+ char name[1];
};
#define NAME_TABLE_SIZE 4096
* return a pointer to its entry, otherwise return a null pointer.
*/
static struct name_ent *
-nametable_find(xfs_dahash_t hash, int namelen, unsigned char *name)
+nametable_find(xfs_dahash_t hash, int namelen, char *name)
{
struct name_ent *ent;
* name's new entry, or a null pointer if an error occurs.
*/
static struct name_ent *
-nametable_add(xfs_dahash_t hash, int namelen, unsigned char *name)
+nametable_add(xfs_dahash_t hash, int namelen, char *name)
{
struct name_ent *ent;
remaptable_find(
xfs_ino_t dir_ino,
xfs_dahash_t namehash,
- const unsigned char *name,
+ const char *name,
unsigned int namelen)
{
struct remap_ent *ent = remaptable[namehash % REMAP_TABLE_SIZE];
remaptable_add(
xfs_ino_t dir_ino,
xfs_dahash_t namehash,
- const unsigned char *old_name,
+ const char *old_name,
unsigned int namelen,
- const unsigned char *new_name)
+ const char *new_name)
{
struct remap_ent *ent;
struct xfs_mount *mp,
xfs_ino_t dir_ino,
size_t name_len,
- unsigned char *name)
+ char *name)
{
return dir_ino == mp->m_sb.sb_rootino &&
name_len == ORPHANAGE_LEN &&
in_lost_found(
xfs_ino_t ino,
int namelen,
- unsigned char *name)
+ char *name)
{
static xfs_ino_t orphanage_ino = 0;
char s[24]; /* 21 is enough (64 bits in decimal) */
* are already in the table.
*/
static int
-handle_duplicate_name(xfs_dahash_t hash, size_t name_len, unsigned char *name)
+handle_duplicate_name(xfs_dahash_t hash, size_t name_len, char *name)
{
- unsigned char new_name[name_len + 1];
+ char new_name[name_len + 1];
uint32_t seq = 1;
if (!nametable_find(hash, name_len, name))
static inline xfs_dahash_t
dirattr_hashname(
bool is_dirent,
- const uint8_t *name,
+ const char *name,
int namelen)
{
if (is_dirent) {
generate_obfuscated_name(
xfs_ino_t ino,
int namelen,
- unsigned char *name)
+ char *name)
{
- unsigned char *orig_name = NULL;
+ char *orig_name = NULL;
xfs_dahash_t hash;
/*
if (metadump.obfuscate)
generate_obfuscated_name(
libxfs_dir2_sf_get_ino(mp, sfp, sfep),
- namelen, &sfep->name[0]);
+ namelen, (char *)&sfep->name[0]);
sfep = (xfs_dir2_sf_entry_t *)((char *)sfep +
libxfs_dir2_sf_entsize(mp, sfp, namelen));
*/
static void
obfuscate_path_components(
- char *buf,
+ char *comp,
uint64_t len)
{
- unsigned char *comp = (unsigned char *)buf;
- unsigned char *end = comp + len;
+ char *end = comp + len;
xfs_dahash_t hash;
while (comp < end) {
static void
maybe_obfuscate_pptr(
unsigned int attr_flags,
- uint8_t *name,
+ char *name,
int namelen,
const void *value,
int valuelen)
{
- unsigned char old_name[MAXNAMELEN];
+ char old_name[MAXNAMELEN];
struct remap_ent *remap;
xfs_dahash_t hash;
xfs_ino_t child_ino = metadump.cur_ino;
if (metadump.obfuscate)
generate_obfuscated_name(be64_to_cpu(dep->inumber),
- dep->namelen, &dep->name[0]);
+ dep->namelen, (char *)&dep->name[0]);
dir_offset += length;
ptr += length;
/* Zero the unused space after name, up to the tag */
be32_to_cpu(remote->valuelen));
} else if (metadump.obfuscate) {
generate_obfuscated_name(0, remote->namelen,
- &remote->name[0]);
+ (char *)&remote->name[0]);
add_remote_vals(be32_to_cpu(remote->valueblk),
be32_to_cpu(remote->valuelen));
}
for (i = 0; i < dirpath->depth; i++) {
struct xfs_name xname = {
- .name = (unsigned char *)dirpath->path[i],
+ .name = dirpath->path[i],
.len = strlen(dirpath->path[i]),
};
uint8_t dtype)
{
char *display_name;
- struct xfs_name xname = { .name = (unsigned char *)name };
+ struct xfs_name xname = { .name = name };
const char *dstr = get_dstr(mp, dtype);
xfs_dahash_t hash;
bool good;
pptr_emit(
struct xfs_inode *ip,
unsigned int attr_flags,
- const uint8_t *name,
+ const char *name,
unsigned int namelen,
const void *value,
unsigned int valuelen)
sfe = libxfs_attr_sf_firstentry(hdr);
for (i = 0; i < hdr->count; i++) {
- pptr_emit(ip, sfe->flags, sfe->nameval, sfe->namelen,
+ pptr_emit(ip, sfe->flags, (char *)sfe->nameval, sfe->namelen,
sfe->nameval + sfe->valuelen, sfe->valuelen);
sfe = xfs_attr_sf_nextentry(sfe);
continue;
name_loc = xfs_attr3_leaf_name_local(leaf, i);
- pptr_emit(ip, entry->flags, name_loc->nameval,
+ pptr_emit(ip, entry->flags, (char *)name_loc->nameval,
name_loc->namelen,
name_loc->nameval + name_loc->namelen,
be16_to_cpu(name_loc->valuelen));
xfs_ino_t child_ino)
{
struct xfs_name xname = {
- .name = (const unsigned char *)name,
+ .name = name,
.len = strlen(name),
.type = ftype,
};
const char *name)
{
struct xfs_name xname = {
- .name = (const unsigned char *)name,
+ .name = name,
.len = strlen(name),
};
struct xfs_parent_args *ppargs;
obfuscate_name(
xfs_dahash_t hash,
size_t name_len,
- unsigned char *name,
+ char *_name,
bool is_dirent)
{
+ unsigned char *name = (unsigned char *)_name;
unsigned char *oldname = NULL;
unsigned char *newp;
int i;
int
find_alternate(
size_t name_len,
- unsigned char *name,
+ char *_name,
uint32_t seq)
{
+ unsigned char *name = (unsigned char *)_name;
uint32_t bitseq = 0;
uint32_t bits = seq;
#define is_invalid_char(c) ((c) == '/' || (c) == '\0')
-void obfuscate_name(xfs_dahash_t hash, size_t name_len, unsigned char *name,
+void obfuscate_name(xfs_dahash_t hash, size_t name_len, char *name,
bool is_dirent);
-int find_alternate(size_t name_len, unsigned char *name, uint32_t seq);
+int find_alternate(size_t name_len, char *name, uint32_t seq);
#endif /* __DB_OBFUSCATE_H__ */
bytes += 2 * dahash_tests[i].length;
hash ^= libxfs_da_hashname(
- randbytes_test_buf + dahash_tests[i].start,
+ (char *)randbytes_test_buf +
+ dahash_tests[i].start,
dahash_tests[i].length);
}
gettimeofday(&start, NULL);
for (i = 0; i < ARRAY_SIZE(dahash_tests); i++) {
hash = libxfs_da_hashname(
- randbytes_test_buf + dahash_tests[i].start,
+ (char *)randbytes_test_buf +
+ dahash_tests[i].start,
dahash_tests[i].length);
if (hash != dahash_tests[i].dahash)
errors++;
- xname.name = randbytes_test_buf + dahash_tests[i].start;
+ xname.name = (char *)randbytes_test_buf +
+ dahash_tests[i].start;
xname.len = dahash_tests[i].length;
hash = libxfs_ascii_ci_hashname(&xname);
if (hash != dahash_tests[i].ascii_ci_dahash)
for (i = 0; i < attrlist->al_count; i++) {
struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i);
- const char *p =
- attr_name_to_fsprop_name(ent->a_name);
+ const char *p;
+ p = attr_name_to_fsprop_name(ent->a_name);
if (p) {
ret = walk_fn(fph, p, ent->a_valuelen, priv);
if (ret)
sfe = libxfs_attr_sf_firstentry(hdr);
for (i = 0; i < hdr->count; i++) {
- error = attr_fn(tp, ip, sfe->flags, sfe->nameval, sfe->namelen,
+ error = attr_fn(tp, ip, sfe->flags,
+ (char *)sfe->nameval, sfe->namelen,
&sfe->nameval[sfe->namelen], sfe->valuelen,
priv);
if (error)
valuelen = be32_to_cpu(name_rmt->valuelen);
}
- error = attr_fn(tp, ip, entry->flags, name, namelen, value,
- valuelen, priv);
+ error = attr_fn(tp, ip, entry->flags, (char *)name, namelen,
+ value, valuelen, priv);
if (error)
return error;
#define __LIBXFS_LISTXATTR_H__
typedef int (*xattr_walk_fn)(struct xfs_trans *tp, struct xfs_inode *ip,
- unsigned int attr_flags,
- const unsigned char *name, unsigned int namelen,
+ unsigned int attr_flags, const char *name, unsigned int namelen,
const void *value, unsigned int valuelen, void *priv);
int xattr_walk(struct xfs_trans *tp, struct xfs_inode *ip,
mode |= val;
creds.cr_uid = (int)getnum(getstr(pp), 0, 0, false);
creds.cr_gid = (int)getnum(getstr(pp), 0, 0, false);
- xname.name = (unsigned char *)name;
+ xname.name = name;
xname.len = name ? strlen(name) : 0;
xname.type = 0;
flags = XFS_ILOG_CORE;
* ordering anyway in case both the name value and the
* hashvalue were wrong but matched. Unlikely, however.
*/
- computed = libxfs_attr_hashval(mp, entry->flags, local->nameval,
+ computed = libxfs_attr_hashval(mp, entry->flags, (char *)local->nameval,
local->namelen,
local->nameval + local->namelen,
be16_to_cpu(local->valuelen));
remotep = xfs_attr3_leaf_name_remote(leaf, i);
- computed = libxfs_attr_hashval(mp, entry->flags, remotep->name,
+ computed = libxfs_attr_hashval(mp, entry->flags, (char *)remotep->name,
remotep->namelen, NULL,
be32_to_cpu(remotep->valuelen));
if (remotep->namelen == 0 ||
short junkit; /* name starts with / */
short seen; /* have seen leaf entry */
struct xfs_name name;
- unsigned char namebuf[];
+ char namebuf[];
};
struct dir_hash_tab {
uint32_t addr,
xfs_ino_t inum,
int namelen,
- unsigned char *name,
+ char *name,
uint8_t ftype)
{
xfs_dahash_t hash = 0;
.mode = S_IFDIR | 0755,
};
struct xfs_name xname = {
- .name = (unsigned char *)ORPHANAGE,
+ .name = ORPHANAGE,
.len = strlen(ORPHANAGE),
.type = XFS_DIR3_FT_DIR,
};
do_error(
_("can't make %s, createname error %d\n"),
ORPHANAGE, error);
- add_parent_ptr(du.ip->i_ino, (unsigned char *)ORPHANAGE, du.dp, false);
+ add_parent_ptr(du.ip->i_ino, ORPHANAGE, du.dp, false);
/*
* We bumped up the link count in the root directory to account
xfs_inode_t *ino_p;
xfs_trans_t *tp;
int err;
- unsigned char fname[MAXPATHLEN + 1];
+ char fname[MAXPATHLEN + 1];
int nres;
int incr;
ino_tree_node_t *irec;
* check for duplicate names in directory.
*/
dup_inum = dir_hash_add(mp, hashtab, addr, inum, dep->namelen,
- dep->name, libxfs_dir2_data_get_ftype(mp, dep));
+ (char *)dep->name,
+ libxfs_dir2_data_get_ftype(mp, dep));
if (dup_inum != NULLFSINO) {
nbad++;
if (entry_junked(
diroffset = xfs_dir2_byte_to_dataptr(
xfs_dir2_sf_get_offset(sfep));
dup_inum = dir_hash_add(mp, hashtab, diroffset,
- lino, sfep->namelen, sfep->name,
+ lino, sfep->namelen, (char *)sfep->name,
libxfs_dir2_sf_get_ftype(mp, sfep));
if (dup_inum != NULLFSINO) {
do_warn(
void
add_parent_ptr(
xfs_ino_t ino,
- const unsigned char *fname,
+ const char *fname,
struct xfs_inode *dp,
bool possible_dup)
{
struct xfs_mount *mp = dp->i_mount;
struct xfs_name dname = {
.name = fname,
- .len = strlen((char *)fname),
+ .len = strlen(fname),
};
struct ag_pptr ag_pptr = {
.child_agino = XFS_INO_TO_AGINO(mp, ino),
struct xfs_inode *ip,
struct file_scan *fscan,
unsigned int attr_filter,
- const unsigned char *name,
+ const char *name,
unsigned int namelen,
const void *value,
unsigned int valuelen)
struct xfs_trans *tp,
struct xfs_inode *ip,
unsigned int attr_flags,
- const unsigned char *name,
+ const char *name,
unsigned int namelen,
const void *value,
unsigned int valuelen,
load_file_pptr_name(
struct file_scan *fscan,
const struct file_pptr *file_pptr,
- unsigned char *name)
+ char *name)
{
if (file_pptr->name_in_nameblobs)
return strblobs_load(nameblobs, file_pptr->name_cookie,
add_file_pptr(
struct xfs_inode *ip,
const struct ag_pptr *ag_pptr,
- const unsigned char *name)
+ const char *name)
{
struct xfs_name xname = {
.name = name,
remove_file_pptr(
struct xfs_inode *ip,
const struct file_pptr *file_pptr,
- const unsigned char *name)
+ const char *name)
{
struct xfs_name xname = {
.name = name,
strerror(error));
while ((file_pptr = pop_slab_cursor(cur)) != NULL) {
- unsigned char name[MAXNAMELEN];
+ char name[MAXNAMELEN];
error = load_file_pptr_name(fscan, file_pptr, name);
if (error)
struct file_scan *fscan,
const struct ag_pptr *ag_pptr)
{
- unsigned char name[MAXNAMELEN];
+ char name[MAXNAMELEN];
int error;
error = strblobs_load(nameblobs, ag_pptr->name_cookie, name,
struct file_scan *fscan,
const struct file_pptr *file_pptr)
{
- unsigned char name[MAXNAMELEN] = { };
+ char name[MAXNAMELEN] = { };
int error;
error = load_file_pptr_name(fscan, file_pptr, name);
const struct ag_pptr *ag_pptr,
const struct file_pptr *file_pptr)
{
- unsigned char name1[MAXNAMELEN] = { };
- unsigned char name2[MAXNAMELEN] = { };
+ char name1[MAXNAMELEN] = { };
+ char name2[MAXNAMELEN] = { };
int error;
error = strblobs_load(nameblobs, ag_pptr->name_cookie, name1,
void parent_ptr_free(struct xfs_mount *mp);
void parent_ptr_init(struct xfs_mount *mp);
-void add_parent_ptr(xfs_ino_t ino, const unsigned char *fname,
- struct xfs_inode *dp, bool possible_dup);
+void add_parent_ptr(xfs_ino_t ino, const char *fname, struct xfs_inode *dp,
+ bool possible_dup);
void check_parent_ptrs(struct xfs_mount *mp);
__strblobs_lookup(
struct strblobs *sblobs,
xfblob_cookie *str_cookie,
- const unsigned char *str,
+ const char *str,
unsigned int str_len,
xfs_dahash_t str_hash)
{
struct strblob_hashent *ent;
- unsigned char *buf = NULL;
+ char *buf = NULL;
unsigned int bucket;
int error;
strblobs_lookup(
struct strblobs *sblobs,
xfblob_cookie *str_cookie,
- const unsigned char *str,
+ const char *str,
unsigned int str_len,
xfs_dahash_t str_hash)
{
strblobs_hash(
struct strblobs *sblobs,
xfblob_cookie str_cookie,
- const unsigned char *str,
+ const char *str,
unsigned int str_len,
xfs_dahash_t str_hash)
{
strblobs_store(
struct strblobs *sblobs,
xfblob_cookie *str_cookie,
- const unsigned char *str,
+ const char *str,
unsigned int str_len,
xfs_dahash_t str_hash)
{
strblobs_load(
struct strblobs *sblobs,
xfblob_cookie str_cookie,
- unsigned char *str,
+ char *str,
unsigned int str_len)
{
return -xfblob_load(sblobs->strings, str_cookie, str, str_len);
void strblobs_destroy(struct strblobs **sblobs);
int strblobs_store(struct strblobs *sblobs, xfblob_cookie *str_cookie,
- const unsigned char *str, unsigned int str_len,
- xfs_dahash_t hash);
+ const char *str, unsigned int str_len, xfs_dahash_t hash);
int strblobs_load(struct strblobs *sblobs, xfblob_cookie str_cookie,
- unsigned char *str, unsigned int str_len);
+ char *str, unsigned int str_len);
int strblobs_lookup(struct strblobs *sblobs, xfblob_cookie *str_cookie,
- const unsigned char *str, unsigned int str_len,
+ const char *str, unsigned int str_len,
xfs_dahash_t hash);
#endif /* __REPAIR_STRBLOBS_H__ */