From 1c7c01420d592e0e87e532ac688e61d5a2fafab2 Mon Sep 17 00:00:00 2001 From: Larry Dewey Date: Thu, 9 Jan 2020 14:36:45 -0700 Subject: [PATCH] libfs: Fixing issue with variable name collision Due to the structure of the old code, variable name collisions were occuring when building with the `-fno-common` flag. These changes fix the problem. [LD: BSC#1160272] Signed-off-by: Larry Dewey --- fscklog/display.c | 4 +- libfs/logredo.c | 127 +++++++++++++++++++++++----------------------- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/fscklog/display.c b/fscklog/display.c index a33d44f..ecb48ca 100644 --- a/fscklog/display.c +++ b/fscklog/display.c @@ -54,7 +54,7 @@ FILE *infp; * output: fsck extracted service log I/O buffer * */ -char xchklog_buffer[XCHKLOG_BUFSIZE]; +char display_xchklog_buffer[XCHKLOG_BUFSIZE]; /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * @@ -98,7 +98,7 @@ int xchkdmp(struct fscklog_record *local_recptr) * Initialize the fscklog control block */ local_recptr->infile_buf_length = XCHKLOG_BUFSIZE; - local_recptr->infile_buf_ptr = xchklog_buffer; + local_recptr->infile_buf_ptr = display_xchklog_buffer; local_recptr->highest_msg_num = fsck_highest_msgid_defined + JFSCHKLOG_FIRSTMSGNUM; diff --git a/libfs/logredo.c b/libfs/logredo.c index eb897e8..c9934db 100644 --- a/libfs/logredo.c +++ b/libfs/logredo.c @@ -87,9 +87,9 @@ int32_t bmap_stg_bytes = 0; * S T U F F F O R T H E L O G * */ -struct logsuper logsup; /* log super block */ -int32_t numdoblk; /* number of do blocks used */ -int32_t numnodofile; /* number of nodo file blocks used */ +struct logsuper global_logsup; /* log super block */ +int32_t logredo_numdoblk; /* number of do blocks used */ +int32_t logredo_numnodofile; /* number of nodo file blocks used */ int32_t numExtDtPg = 0; /* number of extended dtpage blocks used */ /* @@ -129,7 +129,7 @@ int32_t use_2ndary_agg_superblock; */ /* buffer header table */ -struct bufhdr { +struct logredo_bufhdr { int16_t next; /* 2: next on free/lru list */ int16_t prev; /* 2: previous on free/lru list */ int16_t hnext; /* 2: next on hash chain */ @@ -139,27 +139,28 @@ struct bufhdr { int16_t reserve; /* 2 */ int32_t vol; /* 4: minor of agrregate/lv number */ pxd_t pxd; /* 8: on-disk page pxd */ -} bufhdr[NBUFPOOL]; /* (24) */ +} logredo_bufhdr[NBUFPOOL]; /* (24) */ /* buffer table */ struct bufpool { char bytes[PSIZE]; -} buffer[NBUFPOOL - 1]; +} logredo_buffer[NBUFPOOL - 1]; /* * log page buffer cache * * log has its own 4 page buffer pool. */ -uint8_t afterdata[LOGPSIZE * 2]; /* buffer to read in redopage data */ +uint8_t logredo_afterdata[LOGPSIZE * 2]; /* buffer to read in redopage data */ /* * Miscellaneous */ -caddr_t prog; /* Program name */ -int32_t mntcnt, bufsize; -char *mntinfo; -int32_t retcode; /* return code from logredo */ +caddr_t logredo_prog; /* Program name */ +extern int32_t mntcnt; +int32_t logredo_bufsize; +char *logredo_mntinfo; +int32_t logredo_retcode; /* return code from logredo */ int end_of_transaction = 0; /* @@ -489,8 +490,8 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) /* * loop until we get enough memory to read vmount struct */ - mntinfo = (char *) &bufsize; - bufsize = sizeof (int); + logredo_mntinfo = (char *) &logredo_bufsize; + logredo_bufsize = sizeof (int); /* * validate that the log is not currently in use; @@ -517,21 +518,21 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) rc = ujfs_rw_diskblocks(Log.fp, (uint64_t) (Log.xaddr + LOGPNTOB(LOGSUPER_B)), - (unsigned) sizeof (struct logsuper), (char *) &logsup, GET); + (unsigned) sizeof (struct logsuper), (char *) &global_logsup, GET); if (rc != 0) { fsck_send_msg(lrdo_CANTREADLOGSUP); rc = LOGSUPER_READ_ERROR; goto error_out; } - ujfs_swap_logsuper(&logsup); + ujfs_swap_logsuper(&global_logsup); - if (logsup.magic != LOGMAGIC) { + if (global_logsup.magic != LOGMAGIC) { fsck_send_msg(lrdo_LOGSUPBADMGC); rc = NOT_LOG_FILE_ERROR; goto error_out; } - if (logsup.version > LOGVERSION) { + if (global_logsup.version > LOGVERSION) { fsck_send_msg(lrdo_LOGSUPBADVER); rc = JFS_VERSION_ERROR; goto error_out; @@ -551,7 +552,7 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) } } - if (logsup.state == LOGREDONE) { + if (global_logsup.state == LOGREDONE) { fsck_send_msg(lrdo_ALREADYREDONE); if (Log.location & INLINELOG) if ((rc = updateSuper(0)) != 0) { @@ -561,8 +562,8 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) return (0); } - Log.size = logsup.size; - Log.serial = logsup.serial; + Log.size = global_logsup.size; + Log.serial = global_logsup.serial; /* * find the end of log @@ -574,10 +575,10 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) fsck_send_msg(lrdo_LOGENDBAD1); logError(LOGEND, 0); - ujfs_swap_logsuper(&logsup); + ujfs_swap_logsuper(&global_logsup); rc = ujfs_rw_diskblocks(Log.fp, (Log.xaddr + LOGPNTOB(LOGSUPER_B)), - (unsigned long) LOGPSIZE, (char *) &logsup, PUT); + (unsigned long) LOGPSIZE, (char *) &global_logsup, PUT); rc = logend; goto error_out; } @@ -592,7 +593,7 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) goto error_out; } - highest_lr_byte = logsup.size * LOGPSIZE - LOGRDSIZE; + highest_lr_byte = global_logsup.size * LOGPSIZE - LOGRDSIZE; if ((logend < lowest_lr_byte) || (logend > highest_lr_byte)) { fsck_send_msg(lrdo_LOGEND, logend); @@ -614,7 +615,7 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) do { logaddr = nextaddr; - nextaddr = logRead(logaddr, &ld, afterdata); + nextaddr = logRead(logaddr, &ld, logredo_afterdata); DBG_TRACE(("Logaddr=%x\nNextaddr=%x\n", logaddr, nextaddr)) nlogrecords += 1; /* @@ -745,7 +746,7 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) */ if (end_of_transaction != 0) { for (k = 1; k < NBUFPOOL; k++) { - if ((rc = bflush(k, &buffer[k - 1])) != 0) + if ((rc = bflush(k, &logredo_buffer[k - 1])) != 0) goto error_out; } end_of_transaction = 0; @@ -768,7 +769,7 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) * flush data page buffer cache */ for (k = 1; k < NBUFPOOL; k++) { - if ((rc = bflush(k, &buffer[k - 1])) != 0) + if ((rc = bflush(k, &logredo_buffer[k - 1])) != 0) break; } @@ -810,17 +811,17 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) * versions of the operating system. Therefore switch the magic * number to the earliest level. */ - if (logsup.state != LOGREADERR) { + if (global_logsup.state != LOGREADERR) { for (k = 0; k < MAX_ACTIVE; k++) - uuid_clear(logsup.active[k]); + uuid_clear(global_logsup.active[k]); - logsup.end = logend; - logsup.state = LOGREDONE; - logsup.magic = LOGMAGIC; + global_logsup.end = logend; + global_logsup.state = LOGREDONE; + global_logsup.magic = LOGMAGIC; } - ujfs_swap_logsuper(&logsup); + ujfs_swap_logsuper(&global_logsup); rc = ujfs_rw_diskblocks(Log.fp, (Log.xaddr + LOGPNTOB(LOGSUPER_B)), - LOGPSIZE, (char *) &logsup, PUT); + LOGPSIZE, (char *) &global_logsup, PUT); /* * now log some info for the curious @@ -833,9 +834,9 @@ int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper) fsck_send_msg(lrdo_RPTNUMLOGREC, nlogrecords); - fsck_send_msg(lrdo_RPTNUMDOBLK, numdoblk); + fsck_send_msg(lrdo_RPTNUMDOBLK, logredo_numdoblk); - fsck_send_msg(lrdo_RPTNUMNODOBLK, numnodofile); + fsck_send_msg(lrdo_RPTNUMNODOBLK, logredo_numnodofile); error_out: @@ -954,18 +955,18 @@ int openVol(int vol) * Now that the aggregate superblock has been read, do some * more validation of the log superblock */ - if (logsup.bsize != vopen[vol].lblksize) { + if (global_logsup.bsize != vopen[vol].lblksize) { fsck_send_msg(lrdo_LOGSUPBADBLKSZ); return JFS_BLKSIZE_ERROR; } - if (logsup.l2bsize != vopen[vol].l2bsize) { + if (global_logsup.l2bsize != vopen[vol].l2bsize) { fsck_send_msg(lrdo_LOGSUPBADL2BLKSZ); return JFS_L2BLKSIZE_ERROR; } - aggsb_numpages = lengthPXD(&sb.s_logpxd) * logsup.bsize / LOGPSIZE; - if (logsup.size != aggsb_numpages) { + aggsb_numpages = lengthPXD(&sb.s_logpxd) * global_logsup.bsize / LOGPSIZE; + if (global_logsup.size != aggsb_numpages) { fsck_send_msg(lrdo_LOGSUPBADLOGSZ); return JFS_LOGSIZE_ERROR; } @@ -1139,14 +1140,14 @@ int bflush(int32_t k, /* The index in bufhdr that describes buf */ int64_t blkno; /* nothing to do ? */ - if (bufhdr[k].modify == 0) + if (logredo_bufhdr[k].modify == 0) return (0); /* write it out */ - vol = bufhdr[k].vol; + vol = logredo_bufhdr[k].vol; fp = vopen[vol].fp; - blkno = addressPXD(&bufhdr[k].pxd); - nbytes = lengthPXD(&bufhdr[k].pxd) << vopen[vol].l2bsize; + blkno = addressPXD(&logredo_bufhdr[k].pxd); + nbytes = lengthPXD(&logredo_bufhdr[k].pxd) << vopen[vol].l2bsize; rc = ujfs_rw_diskblocks(fp, (uint64_t) (blkno << vopen[vol].l2bsize), (unsigned) nbytes, (char *) buf, PUT); @@ -1155,7 +1156,7 @@ int bflush(int32_t k, /* The index in bufhdr that describes buf */ return (BFLUSH_WRITEERROR); } - bufhdr[k].modify = 0; + logredo_bufhdr[k].modify = 0; return (0); } @@ -1171,7 +1172,7 @@ int bflush(int32_t k, /* The index in bufhdr that describes buf */ */ int findLog(FILE *fp, int *in_use) { - struct logsuper logsup; + struct logsuper findLog_logsup; struct superblock sb; *in_use = 0; @@ -1230,9 +1231,9 @@ int findLog(FILE *fp, int *in_use) } } ujfs_rw_diskblocks(Log.fp, LOGPNTOB(LOGSUPER_B), - sizeof (struct logsuper), &logsup, GET); - ujfs_swap_logsuper(&logsup); - if ((logsup.magic != LOGMAGIC) || (uuid_compare(logsup.uuid, sb.s_loguuid))) { + sizeof (struct logsuper), &findLog_logsup, GET); + ujfs_swap_logsuper(&findLog_logsup); + if ((findLog_logsup.magic != LOGMAGIC) || (uuid_compare(findLog_logsup.uuid, sb.s_loguuid))) { fclose(Log.fp); *in_use = 0; goto by_uuid; @@ -1253,9 +1254,9 @@ int findLog(FILE *fp, int *in_use) /* * is this an external log? */ - ujfs_rw_diskblocks(fp, LOGPNTOB(LOGSUPER_B), sizeof (struct logsuper), &logsup, GET); - ujfs_swap_logsuper(&logsup); - if (logsup.magic != LOGMAGIC) { + ujfs_rw_diskblocks(fp, LOGPNTOB(LOGSUPER_B), sizeof (struct logsuper), &findLog_logsup, GET); + ujfs_swap_logsuper(&findLog_logsup); + if (global_logsup.magic != LOGMAGIC) { fsck_send_msg(lrdo_NOTAFSDEV); return NOT_FSDEV_ERROR; } @@ -1280,7 +1281,7 @@ int fsError(int type, /* error types */ fsck_send_msg(lrdo_ERRORONVOL, vol); - retcode = -1; + logredo_retcode = -1; vopen[vol].status = FM_LOGREDO; switch (type) { @@ -1320,8 +1321,8 @@ int fsError(int type, /* error types */ int logError(int type, int logaddr) { int k; - retcode = -1; - logsup.state = LOGREADERR; + logredo_retcode = -1; + global_logsup.state = LOGREADERR; switch (type) { case LOGEND: fsck_send_msg(lrdo_FINDLOGENDFAIL); @@ -1376,12 +1377,12 @@ static int recoverExtendFS(FILE *fp) * read bmap global control page */ /* read superblock yet again */ - sbp = (struct superblock *) &buffer[0]; + sbp = (struct superblock *) &logredo_buffer[0]; if (rdwrSuper(fp, sbp, PB_READ)) goto errout; /* read primary block allocation map inode */ - dip = (char *) &buffer[1]; + dip = (char *) &logredo_buffer[1]; if (ujfs_rw_diskblocks(fp, AITBL_OFF, PSIZE, dip, GET)) { fsck_send_msg(lrdo_EXTFSREADFSSUPERFAIL); goto errout; @@ -1391,7 +1392,7 @@ static int recoverExtendFS(FILE *fp) dip1 = (struct dinode *) dip; dip1 += BMAP_I; - bp = (char *) &buffer[2]; /* utility buffer */ + bp = (char *) &logredo_buffer[2]; /* utility buffer */ /* start from root in dinode */ p = (xtpage_t *) & dip1->di_btroot; @@ -1660,15 +1661,15 @@ static int recoverExtendFS(FILE *fp) */ /* read log superblock */ t64 = (addressPXD(&sbp->s_logpxd) << sbp->s_l2bsize) + LOGPSIZE; - if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &logsup, GET)) { + if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &global_logsup, GET)) { fsck_send_msg(lrdo_EXTFSREADLOGSUPFAIL); goto errout; } - logsup.end = findEndOfLog(); - logsup.state = LOGREDONE; + global_logsup.end = findEndOfLog(); + global_logsup.state = LOGREDONE; - if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &logsup, PUT)) { + if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &global_logsup, PUT)) { fsck_send_msg(lrdo_EXTFSWRITELOGSUPFAIL); goto errout; } @@ -1791,11 +1792,11 @@ static int nfsisloaded() if (entry = load("/usr/sbin/probe", 0, 0)) return (1); if (errno == ENOEXEC) { - DBG_TRACE(("%s: nfs is not loaded\n", prog)) + DBG_TRACE(("%s: nfs is not loaded\n", logredo_prog)) return (0); } sav_errno = errno; - DBG_TRACE(("%s: ", prog)) + DBG_TRACE(("%s: ", logredo_prog)) errno = sav_errno; perror("load"); return (0); -- 2.24.1