* needed for all columns.
*/
for (i = 0; i < map->bmv_entries; i++) {
- sprintf(rbuf, "[%lld..%lld]:",
+ snprintf(rbuf, sizeof(rbuf), "[%lld..%lld]:",
(long long) map[i + 1].bmv_offset,
(long long)(map[i + 1].bmv_offset +
map[i + 1].bmv_length - 1LL));
tot_w = max(tot_w,
numlen(map[i+1].bmv_length));
} else {
- sprintf(bbuf, "%lld..%lld",
+ snprintf(bbuf, sizeof(bbuf), "%lld..%lld",
(long long) map[i + 1].bmv_block,
(long long)(map[i + 1].bmv_block +
map[i + 1].bmv_length - 1LL));
agno = map[i + 1].bmv_block / bbperag;
agoff = map[i + 1].bmv_block - (agno * bbperag);
- sprintf(abuf, "(%lld..%lld)",
+ snprintf(abuf, sizeof(abuf), "(%lld..%lld)",
(long long)agoff, (long long)
(agoff + map[i + 1].bmv_length - 1LL));
foff_w = max(foff_w, strlen(rbuf));
aoff_w, "AG-OFFSET",
tot_w, "TOTAL");
for (i = 0; i < map->bmv_entries; i++) {
- sprintf(rbuf, "[%lld..%lld]:",
+ snprintf(rbuf, sizeof(rbuf), "[%lld..%lld]:",
(long long) map[i + 1].bmv_offset,
(long long)(map[i + 1].bmv_offset +
map[i + 1].bmv_length - 1LL));
aoff_w, "",
tot_w, (long long)map[i+1].bmv_length);
} else {
- sprintf(bbuf, "%lld..%lld",
+ snprintf(bbuf, sizeof(bbuf), "%lld..%lld",
(long long) map[i + 1].bmv_block,
(long long)(map[i + 1].bmv_block +
map[i + 1].bmv_length - 1LL));
agno = map[i + 1].bmv_block / bbperag;
agoff = map[i + 1].bmv_block - (agno * bbperag);
- sprintf(abuf, "(%lld..%lld)",
+ snprintf(abuf, sizeof(abuf), "(%lld..%lld)",
(long long)agoff, (long long)
(agoff + map[i + 1].bmv_length - 1LL));
printf("%4d: %-*s %-*s %*d %-*s %*lld\n",
len = (int)(strlen(oldpath) + strlen(parent) + 2);
path = xmalloc(len);
- sprintf(path, "%s/%s", parent, oldpath);
+ snprintf(path, len, "%s/%s", parent, oldpath);
return path;
}
int i;
char tagbuf[8];
- for (i = iocur_sp; i >= 0; i--) {
- sprintf(tagbuf, "%d: ", i);
+ for (i = iocur_sp; i > 0; i--) {
+ snprintf(tagbuf, sizeof(tagbuf), "%d: ", i);
print_iocur(tagbuf, &iocur_base[i]);
}
return 0;
add_strvec(&pfx, fl->name);
if (fl->flags & FL_OKLOW) {
add_strvec(&pfx, "[");
- sprintf(buf, "%d", fl->low);
+ snprintf(buf, sizeof(buf), "%d", fl->low);
add_strvec(&pfx, buf);
if (fl->low != fl->high) {
add_strvec(&pfx, "-");
- sprintf(buf, "%d", fl->high);
+ snprintf(buf, sizeof(buf), "%d", fl->high);
add_strvec(&pfx, buf);
}
add_strvec(&pfx, "]");
+[current]
+ - xfs_repair fix to prevent double insertion into the
+ uncertain_inode AVL trees
+ - use snprintf instead of sprintf
+
xfsprogs-1.3.16 (17 December 2001)
- added text dump type to xfs_db (mkp)
- removed use of a temporary file in xfs_db when processing
# -DXR_BLD_ADD_EXTENT track phase 5 block extent creation
# -DXR_BCKPTR_DBG parent list debugging info
#
-CFLAGS += -DAVL_USER_MODE -DAVL_FUTURE_ENHANCEMENTS
+#CFLAGS += ...
install: default
$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
#include <libxfs.h>
-#if defined(STAND_ALONE_DEBUG) || defined(AVL_USER_MODE_DEBUG)
-#define AVL_DEBUG
-#endif
-
#include "avl.h"
#define CERT ASSERT
if ((np = avl_insert_find_growth(tree, start, end, &growth)) == NULL) {
if (start != end) { /* non-zero length range */
-#ifdef AVL_USER_MODE
- printf(
- "avl_insert: Warning! duplicate range [0x%llx,0x%lx)\n",
- (unsigned long long)start, (unsigned long)end);
-#else
- /*
- * lockmetering tree can't afford printfs here.
- */
- if (!(tree->avl_flags & AVLF_DUPLICITY))
- cmn_err(CE_CONT,
- "!avl_insert: Warning! duplicate range [0x%x,0x%x)\n",
- start, end);
-#endif
+ fprintf(stderr,
+ "avl_insert: Warning! duplicate range [%llu,%llu]\n",
+ (unsigned long long)start,
+ (unsigned long long)end);
}
return(NULL);
}
return np;
}
-#ifdef AVL_USER_MODE
-/*
- * leave this as a user-mode only routine until someone actually
- * needs it in the kernel
- */
-
/*
* Returns last in order node
*/
np = np->avl_forw;
return np;
}
-#endif
void
avl_init_tree(avltree_desc_t *tree, avlops_t *ops)
}
-#ifdef AVL_FUTURE_ENHANCEMENTS
/*
* avl_findranges:
*
*endp = avl_findadjacent(tree, (end-1), AVL_PRECEED);
ASSERT(*endp);
}
-
-#endif /* AVL_FUTURE_ENHANCEMENTS */
__psunsigned_t value,
int dir);
-#ifdef AVL_FUTURE_ENHANCEMENTS
void
avl_findranges(
register avltree_desc_t *tree,
register __psunsigned_t end,
avlnode_t **startp,
avlnode_t **endp);
-#endif
#define AVL_PRECEED 0x1
#define AVL_SUCCEED 0x2
* *
**************************************************************************/
-/* to allow use by user-level utilities */
-
-#ifdef STAND_ALONE_DEBUG
-#define AVL_USER_MODE
-#endif
-
-#if defined(STAND_ALONE_DEBUG) || defined(AVL_USER_MODE_DEBUG)
-#define AVL_DEBUG
-#endif
-
#include <stdio.h>
#include <libxfs.h>
#include "avl64.h"
if ((np = avl64_insert_find_growth(tree, start, end, &growth))
== NULL) {
if (start != end) { /* non-zero length range */
-#ifdef AVL_USER_MODE
- printf("avl_insert: Warning! duplicate range [0x%llx,0x%llx)\n",
- (unsigned long long)start, (unsigned long long)end);
-#else
- cmn_err(CE_CONT,
- "!avl_insert: Warning! duplicate range [0x%llx,0x%llx)\n",
- start, end);
-#endif
+ fprintf(stderr,
+ "avl_insert: Warning! duplicate range [%llu,%llu]\n",
+ (unsigned long long)start,
+ (unsigned long long)end);
}
return(NULL);
}
return np;
}
-#ifdef AVL_USER_MODE
-/*
- * leave this as a user-mode only routine until someone actually
- * needs it in the kernel
- */
-
/*
* Returns last in order node
*/
np = np->avl_forw;
return np;
}
-#endif
void
avl64_init_tree(avl64tree_desc_t *tree, avl64ops_t *ops)
}
-#ifdef AVL_FUTURE_ENHANCEMENTS
/*
* avl_findranges:
*
*endp = avl64_findadjacent(tree, (end-1), AVL_PRECEED);
ASSERT(*endp);
}
-
-#endif /* AVL_FUTURE_ENHANCEMENTS */
__uint64_t value,
int dir);
-#ifdef AVL_FUTURE_ENHANCEMENTS
void
avl64_findranges(
register avl64tree_desc_t *tree,
register __uint64_t end,
avl64node_t **startp,
avl64node_t **endp);
-#endif
/*
* avoid complaints about multiple def's since these are only used by
return(0);
/*
- * ok, put the record into the tree. we know that it's
- * not already there since the inode is guaranteed
- * not to be in the tree.
+ * ok, put the record into the tree, if no conflict.
*/
+ if (find_uncertain_inode_rec(agno,
+ XFS_OFFBNO_TO_AGINO(mp, start_agbno, 0)))
+ return(0);
+
start_agino = XFS_OFFBNO_TO_AGINO(mp, start_agbno, 0);
*start_ino = XFS_AGINO_TO_INO(mp, agno, start_agino);
* separate trees for uncertain inodes (they may not exist).
*/
ino_tree_node_t *findfirst_uncertain_inode_rec(xfs_agnumber_t agno);
+ino_tree_node_t *find_uncertain_inode_rec(xfs_agnumber_t agno,
+ xfs_agino_t ino);
void add_inode_uncertain(xfs_mount_t *mp,
xfs_ino_t ino, int free);
void add_aginode_uncertain(xfs_agnumber_t agno,
if (avl_insert(inode_uncertain_tree_ptrs[agno],
(avlnode_t *) ino_rec) == NULL) {
- do_error("xfs_repair: duplicate inode range\n");
+ do_error("xfs_repair: add_aginode_uncertain - "
+ "duplicate inode range\n");
}
}
inode_uncertain_tree_ptrs[agno]->avl_firstino);
}
+ino_tree_node_t *
+find_uncertain_inode_rec(xfs_agnumber_t agno, xfs_agino_t ino)
+{
+ return((ino_tree_node_t *)
+ avl_findrange(inode_uncertain_tree_ptrs[agno], ino));
+}
+
void
clear_uncertain_ino_cache(xfs_agnumber_t agno)
{
if (avl_insert(inode_tree_ptrs[agno],
(avlnode_t *) ino_rec) == NULL) {
- do_error("xfs_repair: duplicate inode range\n");
+ do_warn("xfs_repair: add_inode - duplicate inode range\n");
}
return(ino_rec);
char fname[MAXPATHLEN + 1];
int nres;
- sprintf(fname, "%llu", (unsigned long long)ino);
+ snprintf(fname, sizeof(fname), "%llu", (unsigned long long)ino);
if ((err = libxfs_iget(mp, NULL, dir_ino, 0, &dir_ino_p, 0)))
do_error("%d - couldn't iget orphanage inode\n", err);
/*
* check for a realtime partition
*/
- sprintf(tbuf,"%s",target);
+ snprintf(tbuf, sizeof(tbuf), "%s", target);
if ( stat(target, &s2) ) {
if (!S_ISDIR(s2.st_mode)) {
/* take out target file name */
if ((ptr = strrchr(tbuf, '/')) != NULL)
*ptr = '\0';
else
- sprintf(tbuf, ".");
+ snprintf(tbuf, sizeof(tbuf), ".");
}
}
/*
* check if target is a directory
*/
- sprintf(tbuf,"%s",target);
+ snprintf(tbuf, sizeof(tbuf), "%s", target);
if ( !stat(target, &s2) ) {
if (S_ISDIR(s2.st_mode)) {
- sprintf(tbuf,"%s/%s",target, basename(source));
+ snprintf(tbuf, sizeof(tbuf), "%s/%s", target,
+ basename(source));
}
}