~ubuntu-branches/debian/stretch/jfsutils/stretch

« back to all changes in this revision

Viewing changes to libfs/logredo.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Hornburg (Racke)
  • Date: 2006-08-02 21:15:09 UTC
  • mfrom: (1.2.2 upstream) (2.1.3 breezy)
  • Revision ID: james.westby@ubuntu.com-20060802211509-eoqwjtlgla5tu9dt
* new upstream release fixing stack buffer overflow (Closes: #343638)
* keep only reference to GPL in debian/copyright
* mark udeb package as such properly and create dependencies 
  (Closes: #381245, thanks to Frans Pop <fjp@debian.org> for the patch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 *   This program is free software;  you can redistribute it and/or modify
5
5
 *   it under the terms of the GNU General Public License as published by
6
 
 *   the Free Software Foundation; either version 2 of the License, or 
 
6
 *   the Free Software Foundation; either version 2 of the License, or
7
7
 *   (at your option) any later version.
8
 
 * 
 
8
 *
9
9
 *   This program is distributed in the hope that it will be useful,
10
10
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
11
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12
12
 *   the GNU General Public License for more details.
13
13
 *
14
14
 *   You should have received a copy of the GNU General Public License
15
 
 *   along with this program;  if not, write to the Free Software 
 
15
 *   along with this program;  if not, write to the Free Software
16
16
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
 */
18
 
#include "jfs_types.h"
 
18
#include <config.h>
19
19
#include <time.h>
20
20
#include <stdio.h>
21
21
#include <stdlib.h>
26
26
#include <fcntl.h>
27
27
#include <errno.h>
28
28
#include <assert.h>
 
29
 
 
30
#include "jfs_types.h"
29
31
#include "jfs_endian.h"
30
32
#include "jfs_filsys.h"
31
33
#include "jfs_superblock.h"
39
41
#include "logform.h"
40
42
#include "devices.h"
41
43
#include "debug.h"
42
 
 
 
44
#include "utilsubs.h"
43
45
#include "fsck_message.h"               /* for chkdsk message logging facility */
44
46
 
45
47
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
46
48
 *
47
 
 * For the chkdsk message logging facility
48
 
 *
49
 
 *      defined in xchkdsk.c
50
 
 */
51
 
extern char *verbose_msg_ptr;
52
 
 
53
 
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
54
 
 *
55
49
 *   L O C A L   M A C R O    D E F I N I T I O N S
56
50
 *
57
51
 */
110
104
 *
111
105
 */
112
106
struct vopen vopen[MAX_ACTIVE];
113
 
struct log_info log;
 
107
struct log_info Log;
114
108
struct {
115
109
        uuid_t uuid;
116
 
        int fd;
 
110
        FILE *fp;
117
111
} primary_vol;
118
112
extern int LogOpenMode;         /* logdump sets this to O_RDONLY */
119
113
 
185
179
extern int doNoRedoInoExt(struct lrd *);
186
180
extern int doAfter(struct lrd *, int32_t);
187
181
extern int doUpdateMap(struct lrd *);
188
 
 
189
 
extern int v_fsck_send_msg(int, const char *, int, ...);
190
182
extern int alloc_wrksp(uint32_t, int, int, void **);
191
183
 
192
 
extern int open_by_label(uuid_t, int, int, char *, int *);
 
184
extern FILE * open_by_label(uuid_t, int, int, char *, int *);
193
185
extern char log_device[];
194
186
/*
195
187
 * forward references
197
189
int doMount(struct lrd *);
198
190
int openVol(int32_t);
199
191
int updateSuper(int vol);
200
 
int rdwrSuper(int32_t, struct superblock *, int32_t);
 
192
int rdwrSuper(FILE *, struct superblock *, int32_t);
201
193
int bflush(int32_t, struct bufpool *);
202
194
int logOpen(void);
203
195
int fsError(int, int, int64_t);
204
196
int logError(int, int);
205
 
static int recoverExtendFS(int32_t fd);
 
197
static int recoverExtendFS(FILE *);
206
198
int alloc_storage(int32_t, void **, int32_t *);
207
199
int alloc_dmap_bitrec(struct dmap_bitmaps **);
208
200
 
227
219
 * FUNCTION:    Replay all transactions committed since the most
228
220
 *              recent synch point.
229
221
 *
230
 
 * NOTES:       
 
222
 * NOTES:
231
223
 *      >>>>>>  The log replay is accomplished in one pass over the
232
224
 *              log, reading backwards from logend to the first synch
233
225
 *              point record encountered.  This means that the log
397
389
 * name, get the log minor number for this filesystem. If it is a log name,
398
390
 * get its minor number.
399
391
 *
400
 
 * XJFS decided to put log inside the file system  
 
392
 * XJFS decided to put log inside the file system
401
393
 *
402
394
 * For supporting the inline log, the above AIX logic should be changed.
403
395
 *
476
468
 * if the crash occurs just after writing the super block, the map sizes
477
469
 * are fixed up here.
478
470
 */
479
 
int jfs_logredo(caddr_t pathname, int32_t fd, int32_t use_2nd_aggSuper)
 
471
int jfs_logredo(caddr_t pathname, FILE *fp, int32_t use_2nd_aggSuper)
480
472
{
481
473
        int rc;
482
474
        int k, logaddr, nextaddr, lastaddr, nlogrecords;
503
495
        /*
504
496
         * validate that the log is not currently in use;
505
497
         */
506
 
        rc = findLog(fd, &in_use);
 
498
        rc = findLog(fp, &in_use);
507
499
        if (rc < 0) {
508
500
                fsck_send_msg(lrdo_DEVOPNREADERROR);
509
501
                return (rc);
510
502
        }
511
503
 
512
504
        /* recover from extendfs() ? */
513
 
        if (log.location & INLINELOG && (vopen[0].status & FM_EXTENDFS)) {
 
505
        if (Log.location & INLINELOG && (vopen[0].status & FM_EXTENDFS)) {
514
506
                fsck_send_msg(lrdo_REXTNDBEGIN);
515
 
                rc = recoverExtendFS(fd);
 
507
                rc = recoverExtendFS(fp);
516
508
                fsck_send_msg(lrdo_REXTNDDONE);
517
509
                return rc;
518
510
        }
522
514
         *
523
515
         * aggregate block size is for log file as well.
524
516
         */
525
 
        rc = ujfs_rw_diskblocks(log.fd,
526
 
                                (uint64_t) (log.xaddr +
 
517
        rc = ujfs_rw_diskblocks(Log.fp,
 
518
                                (uint64_t) (Log.xaddr +
527
519
                                            LOGPNTOB(LOGSUPER_B)),
528
520
                                (unsigned) sizeof (struct logsuper), (char *) &logsup, GET);
529
521
        if (rc != 0) {
545
537
                goto error_out;
546
538
        }
547
539
 
548
 
        if (log.location & OUTLINELOG) {
 
540
        if (Log.location & OUTLINELOG) {
549
541
                struct stat st;
550
542
 
551
 
                if ((rc = fstat(log.fd, &st)))
 
543
                if ((rc = fstat(fileno(Log.fp), &st)))
552
544
                        goto error_out;
553
545
 
554
 
                log.devnum = st.st_rdev;
 
546
                Log.devnum = st.st_rdev;
555
547
 
556
548
                if (in_use) {
557
549
                        fsck_send_msg(lrdo_LOGINUSE);
561
553
 
562
554
        if (logsup.state == LOGREDONE) {
563
555
                fsck_send_msg(lrdo_ALREADYREDONE);
564
 
                if (log.location & INLINELOG)
 
556
                if (Log.location & INLINELOG)
565
557
                        if ((rc = updateSuper(0)) != 0) {
566
558
                                fsck_send_msg(lrdo_CANTUPDLOGSUP);
567
559
                                return (rc);
569
561
                return (0);
570
562
        }
571
563
 
572
 
        log.size = logsup.size;
573
 
        log.serial = logsup.serial;
 
564
        Log.size = logsup.size;
 
565
        Log.serial = logsup.serial;
574
566
 
575
567
        /*
576
568
         * find the end of log
583
575
                fsck_send_msg(lrdo_LOGENDBAD1);
584
576
                logError(LOGEND, 0);
585
577
                ujfs_swap_logsuper(&logsup);
586
 
                rc = ujfs_rw_diskblocks(log.fd,
587
 
                                        (log.xaddr + LOGPNTOB(LOGSUPER_B)),
 
578
                rc = ujfs_rw_diskblocks(Log.fp,
 
579
                                        (Log.xaddr + LOGPNTOB(LOGSUPER_B)),
588
580
                                        (unsigned long) LOGPSIZE, (char *) &logsup, PUT);
589
581
                rc = logend;
590
582
                goto error_out;
791
783
                if (vopen[k].state != VOPEN_OPEN)
792
784
                        continue;
793
785
 
794
 
                /* don't update the maps if the aggregate/lv is
795
 
                 * FM_DIRTY since fsck will rebuild maps anyway
796
 
                 */
797
 
                if (!vopen[k].is_fsdirty) {
798
 
                        if ((rc = updateMaps(k)) != 0) {
799
 
                                fsck_send_msg(lrdo_ERRORCANTUPDMAPS);
800
 
                                goto error_out;
801
 
                        }
 
786
                if ((rc = updateMaps(k)) != 0) {
 
787
                        fsck_send_msg(lrdo_ERRORCANTUPDMAPS);
 
788
                        goto error_out;
802
789
                }
803
790
 
804
791
                /* Make sure all changes are committed to disk before we
805
792
                 * mark the superblock clean
806
793
                 */
807
 
                fsync(vopen[k].fd);
 
794
                ujfs_flush_dev(vopen[k].fp);
808
795
 
809
796
                if ((rc = updateSuper(k)) != 0) {
810
797
                        fsck_send_msg(lrdo_ERRORCANTUPDFSSUPER);
812
799
                }
813
800
 
814
801
                /* sync superblock before journal is finalized */
815
 
                fsync(vopen[k].fd);
 
802
                ujfs_flush_dev(vopen[k].fp);
816
803
        }
817
804
 
818
805
        /*
832
819
                logsup.magic = LOGMAGIC;
833
820
        }
834
821
        ujfs_swap_logsuper(&logsup);
835
 
        rc = ujfs_rw_diskblocks(log.fd, (log.xaddr + LOGPNTOB(LOGSUPER_B)),
 
822
        rc = ujfs_rw_diskblocks(Log.fp, (Log.xaddr + LOGPNTOB(LOGSUPER_B)),
836
823
                                LOGPSIZE, (char *) &logsup, PUT);
837
824
 
838
825
        /*
907
894
        struct superblock sb;
908
895
        int aggsb_numpages;
909
896
 
910
 
        if (log.location & OUTLINELOG) {
 
897
        if (Log.location & OUTLINELOG) {
911
898
                /* First check if this is the already opened volume */
912
899
                if (!uuid_compare(vopen[vol].uuid, primary_vol.uuid))
913
 
                        vopen[vol].fd = primary_vol.fd;
 
900
                        vopen[vol].fp = primary_vol.fp;
914
901
                else {
915
 
                        vopen[vol].fd = open_by_label(vopen[vol].uuid, 0, 0,
 
902
                        vopen[vol].fp = open_by_label(vopen[vol].uuid, 0, 0,
916
903
                                                      NULL, NULL);
917
 
                        if (vopen[vol].fd < 0)
 
904
                        if (vopen[vol].fp == NULL)
918
905
                                return ENOENT;
919
906
                }
920
907
        }
921
908
 
922
909
        /* read superblock of the aggregate/volume */
923
 
        if ((rc = rdwrSuper(vopen[vol].fd, &sb, PB_READ)) != 0) {
 
910
        if ((rc = rdwrSuper(vopen[vol].fp, &sb, PB_READ)) != 0) {
924
911
                fsck_send_msg(lrdo_CANTREADFSSUPER);
925
912
 
926
913
                fsError(READERR, vol, SUPER1_B);
942
929
                return (LOGSUPER_BADVERSION);
943
930
        }
944
931
 
945
 
        if (log.location & OUTLINELOG && (sb.s_flag & (JFS_INLINELOG == JFS_INLINELOG))) {
 
932
        if (Log.location & OUTLINELOG && (sb.s_flag & (JFS_INLINELOG == JFS_INLINELOG))) {
946
933
                fsck_send_msg(lrdo_FSSUPERBADLOGLOC);
947
934
                vopen[vol].state = VOPEN_CLOSED;
948
935
                return (LOGSUPER_BADLOGLOC);
962
949
                vopen[vol].numag += 1;
963
950
        vopen[vol].l2agsize = l2agsize;
964
951
 
965
 
        if (log.location & INLINELOG) {
 
952
        if (Log.location & INLINELOG) {
966
953
                /*
967
954
                 * Now that the aggregate superblock has been read, do some
968
955
                 * more validation of the log superblock
1006
993
        /*
1007
994
         *check log serial number
1008
995
         */
1009
 
        if (sb.s_logserial != log.serial) {
 
996
        if (sb.s_logserial != Log.serial) {
1010
997
                fsck_send_msg(lrdo_FSSUPERBADLOGSER);
1011
998
                vopen[vol].state = VOPEN_CLOSED;
1012
999
                fsError(SERIALNO, vol, SUPER1_B);
1036
1023
        struct superblock sb;
1037
1024
 
1038
1025
        /* read in superblock of the volume */
1039
 
        if ((rc = rdwrSuper(vopen[vol].fd, &sb, PB_READ)) != 0) {
 
1026
        if ((rc = rdwrSuper(vopen[vol].fp, &sb, PB_READ)) != 0) {
1040
1027
                fsck_send_msg(lrdo_READFSSUPERFAIL);
1041
1028
                return (FSSUPER_READERROR2);
1042
1029
        }
1048
1035
        else
1049
1036
                sb.s_state = FM_CLEAN;
1050
1037
 
1051
 
        if ((rc = rdwrSuper(vopen[vol].fd, &sb, PB_UPDATE)) != 0) {
 
1038
        if ((rc = rdwrSuper(vopen[vol].fp, &sb, PB_UPDATE)) != 0) {
1052
1039
                fsck_send_msg(lrdo_WRITEFSSUPERFAIL);
1053
1040
        }
1054
1041
 
1056
1043
}
1057
1044
 
1058
1045
/*
1059
 
 * NAME:        rdwrSuper(fd, sb, rwflag)
 
1046
 * NAME:        rdwrSuper(fp, sb, rwflag)
1060
1047
 *
1061
1048
 * FUNCTION:    read or write the superblock for the file system described
1062
1049
 *              by the file descriptor of the opened aggregate/lv.
1065
1052
 *              when both reads failed.
1066
1053
 *              for write, any write failure should be reported.
1067
1054
 */
1068
 
int rdwrSuper(int32_t fd, struct superblock * sb, int32_t rwflag)
 
1055
int rdwrSuper(FILE *fp, struct superblock * sb, int32_t rwflag)
1069
1056
{
1070
1057
        int rc;
1071
1058
        uint64_t super_offset;
1090
1077
         * read super block
1091
1078
         */
1092
1079
        if (rwflag == PB_READ) {
1093
 
                rc = ujfs_rw_diskblocks(fd, super_offset,
 
1080
                rc = ujfs_rw_diskblocks(fp, super_offset,
1094
1081
                                        (unsigned) SIZE_OF_SUPER, super.block, GET);
1095
1082
                if (rc != 0) {
1096
1083
                        if (!use_2ndary_agg_superblock) {
1119
1106
                 * write whichever superblock we're working with.
1120
1107
                 * chkdsk will take care of replicating it.
1121
1108
                 */
1122
 
                rc = ujfs_rw_diskblocks(fd, super_offset,
 
1109
                rc = ujfs_rw_diskblocks(fp, super_offset,
1123
1110
                                        (unsigned) SIZE_OF_SUPER, super.block, PUT);
1124
1111
                if (rc != 0) {
1125
1112
                        if (!use_2ndary_agg_superblock) {
1145
1132
int bflush(int32_t k,           /*  The index in bufhdr that describes buf */
1146
1133
           struct bufpool *buf)
1147
1134
{                               /* pointer to buffer pool page */
 
1135
        FILE *fp = NULL;
1148
1136
        int rc;
1149
 
        int32_t fd, vol;
 
1137
        int32_t vol;
1150
1138
        int32_t nbytes;
1151
1139
        int64_t blkno;
1152
1140
 
1156
1144
 
1157
1145
        /* write it out */
1158
1146
        vol = bufhdr[k].vol;
1159
 
        fd = vopen[vol].fd;
 
1147
        fp = vopen[vol].fp;
1160
1148
        blkno = addressPXD(&bufhdr[k].pxd);
1161
1149
        nbytes = lengthPXD(&bufhdr[k].pxd) << vopen[vol].l2bsize;
1162
 
        rc = ujfs_rw_diskblocks(fd,
 
1150
        rc = ujfs_rw_diskblocks(fp,
1163
1151
                                (uint64_t) (blkno << vopen[vol].l2bsize),
1164
1152
                                (unsigned) nbytes, (char *) buf, PUT);
1165
1153
        if (rc != 0) {
1181
1169
 *              the log device.
1182
1170
 *
1183
1171
 */
1184
 
int findLog(int fd, int *in_use)
 
1172
int findLog(FILE *fp, int *in_use)
1185
1173
{
1186
1174
        struct logsuper logsup;
1187
1175
        struct superblock sb;
1190
1178
        /*
1191
1179
         * try the LV as file system with in-line log
1192
1180
         */
1193
 
        if (rdwrSuper(fd, &sb, PB_READ)) {
 
1181
        if (rdwrSuper(fp, &sb, PB_READ)) {
1194
1182
                fsck_send_msg(lrdo_NOTAFSDEV);
1195
1183
                return NOT_FSDEV_ERROR;
1196
1184
        }
1203
1191
                 * does file system contains its in-line log ?
1204
1192
                 */
1205
1193
                if ((sb.s_flag & JFS_INLINELOG) == JFS_INLINELOG) {
1206
 
                        log.location = INLINELOG;
1207
 
                        log.fd = fd;
1208
 
                        //log.status = sb.s_state;
1209
 
                        log.l2bsize = sb.s_l2bsize;
1210
 
                        log.xaddr = addressPXD(&sb.s_logpxd) << sb.s_l2bsize;
 
1194
                        Log.location = INLINELOG;
 
1195
                        Log.fp = fp;
 
1196
                        //Log.status = sb.s_state;
 
1197
                        Log.l2bsize = sb.s_l2bsize;
 
1198
                        Log.xaddr = addressPXD(&sb.s_logpxd) << sb.s_l2bsize;
1211
1199
 
1212
1200
                        /* vopen[0] represents fs if inline log */
1213
1201
                        vopen[0].status = sb.s_state;
1214
 
                        vopen[0].fd = fd;
 
1202
                        vopen[0].fp = fp;
1215
1203
 
1216
1204
                        return 0;
1217
1205
                }
1218
 
                /* Save fd and uuid */
1219
 
                primary_vol.fd = fd;
 
1206
                /* Save fp and uuid */
 
1207
                primary_vol.fp = fp;
1220
1208
                uuid_copy(primary_vol.uuid, sb.s_uuid);
1221
1209
 
1222
1210
                /*
1225
1213
                 * First check device specified on
1226
1214
                 * command line
1227
1215
                 */
1228
 
                log.xaddr = 0;
 
1216
                Log.xaddr = 0;
1229
1217
                if (log_device[0]) {
1230
 
                        log.fd = open(log_device, LogOpenMode, 0);
1231
 
                        if (log.fd < 0) {
1232
 
                                log.fd = open(log_device, O_RDONLY, 0);
1233
 
                                if (log.fd < 0) {
 
1218
                        Log.fp = NULL;
 
1219
                        if (LogOpenMode != O_RDONLY) {
 
1220
                                Log.fp = fopen_excl(log_device, "r+");
 
1221
                                if (Log.fp == NULL)
 
1222
                                        *in_use = 1;
 
1223
                        }
 
1224
                        if (Log.fp == NULL) {
 
1225
                                Log.fp = fopen(log_device, "r");
 
1226
                                if (Log.fp == NULL) {
1234
1227
                                        printf("Invalid journal specified (%s)\n",
1235
1228
                                               log_device);
1236
1229
                                        goto by_uuid;
1237
1230
                                }
1238
 
                                *in_use = 1;
1239
1231
                        }
1240
 
                        ujfs_rw_diskblocks(log.fd, LOGPNTOB(LOGSUPER_B),
 
1232
                        ujfs_rw_diskblocks(Log.fp, LOGPNTOB(LOGSUPER_B),
1241
1233
                                           sizeof (struct logsuper), &logsup, GET);
1242
1234
                        ujfs_swap_logsuper(&logsup);
1243
1235
                        if ((logsup.magic != LOGMAGIC) || (uuid_compare(logsup.uuid, sb.s_loguuid))) {
1244
 
                                close(log.fd);
 
1236
                                fclose(Log.fp);
1245
1237
                                *in_use = 0;
1246
1238
                                goto by_uuid;
1247
1239
                        }
1248
 
                        log.location = OUTLINELOG;
 
1240
                        Log.location = OUTLINELOG;
1249
1241
                        return 0;
1250
1242
                }
1251
1243
              by_uuid:
1252
 
                log.fd = open_by_label(sb.s_loguuid, 0, 1, NULL, in_use);
 
1244
                Log.fp = open_by_label(sb.s_loguuid, 0, 1, NULL, in_use);
1253
1245
 
1254
 
                if (log.fd >= 0) {
1255
 
                        log.location |= OUTLINELOG;
 
1246
                if (Log.fp != NULL) {
 
1247
                        Log.location |= OUTLINELOG;
1256
1248
                        return 0;
1257
1249
                }
1258
1250
 
1261
1253
        /*
1262
1254
         * is this an external log?
1263
1255
         */
1264
 
        ujfs_rw_diskblocks(fd, LOGPNTOB(LOGSUPER_B), sizeof (struct logsuper), &logsup, GET);
 
1256
        ujfs_rw_diskblocks(fp, LOGPNTOB(LOGSUPER_B), sizeof (struct logsuper), &logsup, GET);
1265
1257
        ujfs_swap_logsuper(&logsup);
1266
1258
        if (logsup.magic != LOGMAGIC) {
1267
1259
                fsck_send_msg(lrdo_NOTAFSDEV);
1268
1260
                return NOT_FSDEV_ERROR;
1269
1261
        }
1270
 
        log.fd = fd;
1271
 
        log.location = OUTLINELOG;
 
1262
        Log.fp = fp;
 
1263
        Log.location = OUTLINELOG;
1272
1264
 
1273
1265
        return 0;
1274
1266
}
1366
1358
 * unknown state;
1367
1359
 *
1368
1360
 * at entry, only log type/lv has been validated;
1369
 
 * for inline log: vopen[0], fs fd = log fd;
 
1361
 * for inline log: vopen[0], fs fp = log fp;
1370
1362
 */
1371
 
static int recoverExtendFS(int32_t fd)
 
1363
static int recoverExtendFS(FILE *fp)
1372
1364
{
1373
1365
        struct superblock *sbp;
1374
1366
        struct dinode *dip1, *dip2;
1385
1377
         */
1386
1378
        /* read superblock yet again */
1387
1379
        sbp = (struct superblock *) &buffer[0];
1388
 
        if (rdwrSuper(fd, sbp, PB_READ))
 
1380
        if (rdwrSuper(fp, sbp, PB_READ))
1389
1381
                goto errout;
1390
1382
 
1391
1383
        /* read primary block allocation map inode */
1392
1384
        dip = (char *) &buffer[1];
1393
 
        if (ujfs_rw_diskblocks(fd, AITBL_OFF, PSIZE, dip, GET)) {
 
1385
        if (ujfs_rw_diskblocks(fp, AITBL_OFF, PSIZE, dip, GET)) {
1394
1386
                fsck_send_msg(lrdo_EXTFSREADFSSUPERFAIL);
1395
1387
                goto errout;
1396
1388
        }
1411
1403
        do {
1412
1404
                /* read in the leftmost child page */
1413
1405
                t64 = addressXAD(&p->xad[XTENTRYSTART]) << sbp->s_l2bsize;
1414
 
                if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1406
                if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1415
1407
                        fsck_send_msg(lrdo_EXTFSREADBLKMAPINOFAIL);
1416
1408
                        goto errout;
1417
1409
                }
1424
1416
 
1425
1417
      rdbgcp:
1426
1418
        t64 = addressXAD(&p->xad[XTENTRYSTART]) << sbp->s_l2bsize;
1427
 
        if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1419
        if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1428
1420
                fsck_send_msg(lrdo_EXTFSREADBLKFAIL1, (long long) t64);
1429
1421
                goto errout;
1430
1422
        }
1446
1438
         */
1447
1439
        /* read 2ndary block allocation map inode */
1448
1440
        t64 = addressPXD(&sbp->s_ait2) << sbp->s_l2bsize;
1449
 
        if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1441
        if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1450
1442
                fsck_send_msg(lrdo_EXTFSREADBLKFAIL2, (long long) t64);
1451
1443
                goto errout;
1452
1444
        }
1463
1455
        memcpy(dip1, dip2, DISIZE);
1464
1456
        memcpy((void *) &(dip1->di_ixpxd), (void *) &temp_pxd, sizeof (pxd_t));
1465
1457
 
1466
 
        if (ujfs_rw_diskblocks(fd, AITBL_OFF, PSIZE, dip, PUT)) {
 
1458
        if (ujfs_rw_diskblocks(fp, AITBL_OFF, PSIZE, dip, PUT)) {
1467
1459
                fsck_send_msg(lrdo_EXTFSWRITEBLKFAIL1, AITBL_OFF);
1468
1460
                goto errout;
1469
1461
        }
1515
1507
                                         * pages
1516
1508
                                         */
1517
1509
                                        p->header.next = 0;
1518
 
                                        if (ujfs_rw_diskblocks(fd, t64, PSIZE, p, PUT)) {
 
1510
                                        if (ujfs_rw_diskblocks(fp, t64, PSIZE, p, PUT)) {
1519
1511
                                                fsck_send_msg(lrdo_EXTFSWRITEBLKFAIL2, (long long) t64);
1520
1512
                                                goto errout;
1521
1513
                                        }
1531
1523
                        if (xaddr) {
1532
1524
                                if (xaddr >= barrier) {
1533
1525
                                        p->header.next = 0;
1534
 
                                        if (ujfs_rw_diskblocks(fd, t64, PSIZE, p, PUT)) {
 
1526
                                        if (ujfs_rw_diskblocks(fp, t64, PSIZE, p, PUT)) {
1535
1527
                                                fsck_send_msg(lrdo_EXTFSWRITEBLKFAIL3, (long long) t64);
1536
1528
                                                break;
1537
1529
                                        }
1538
1530
                                }
1539
1531
 
1540
1532
                                t64 = xaddr << sbp->s_l2bsize;
1541
 
                                if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1533
                                if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1542
1534
                                        fsck_send_msg(lrdo_EXTFSREADBLKFAIL3, (long long) t64);
1543
1535
                                        goto errout;
1544
1536
                                }
1556
1548
                        /* get the leftmost child page  */
1557
1549
                        xaddr = lmchild;
1558
1550
                        t64 = xaddr << sbp->s_l2bsize;
1559
 
                        if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1551
                        if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1560
1552
                                fsck_send_msg(lrdo_EXTFSREADBLKFAIL4, (long long) t64);
1561
1553
                                goto errout;
1562
1554
                        }
1580
1572
         * marked as free by extendfs();
1581
1573
         */
1582
1574
        /* fake log opend/validated */
1583
 
        log.serial = sbp->s_logserial;
 
1575
        Log.serial = sbp->s_logserial;
1584
1576
 
1585
1577
        /*
1586
1578
         *  reconstruct maps
1602
1594
         * request reformat original log  (which might have been
1603
1595
         * overwritten by extendfs() and set superblock clean
1604
1596
         */
1605
 
        jfs_logform(fd, sbp->s_bsize, sbp->s_l2bsize, sbp->s_flag,
 
1597
        jfs_logform(fp, sbp->s_bsize, sbp->s_l2bsize, sbp->s_flag,
1606
1598
                    addressPXD(&sbp->s_logpxd), lengthPXD(&sbp->s_logpxd), NULL, NULL);
1607
1599
 
1608
1600
        /* update superblock */
1621
1613
         */
1622
1614
        /* read 2ndary block allocation map inode */
1623
1615
        t64 = addressPXD(&sbp->s_ait2) << sbp->s_l2bsize;
1624
 
        if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, GET)) {
 
1616
        if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, GET)) {
1625
1617
                fsck_send_msg(lrdo_EXTFSREADBLKFAIL5, (long long) t64);
1626
1618
                goto errout;
1627
1619
        }
1637
1629
        memcpy(dip2, dip1, DISIZE);
1638
1630
        memcpy((void *) &(dip2->di_ixpxd), (void *) &temp_pxd, sizeof (pxd_t));
1639
1631
 
1640
 
        if (ujfs_rw_diskblocks(fd, t64, PSIZE, bp, PUT)) {
 
1632
        if (ujfs_rw_diskblocks(fp, t64, PSIZE, bp, PUT)) {
1641
1633
                fsck_send_msg(lrdo_EXTFSWRITEBLKFAIL4, (long long) t64);
1642
1634
                goto errout;
1643
1635
        }
1656
1648
        sbp->s_logpxd = sbp->s_xlogpxd;
1657
1649
        sbp->s_logserial = 1;
1658
1650
 
1659
 
        if (rdwrSuper(fd, sbp, PB_UPDATE)) {
 
1651
        if (rdwrSuper(fp, sbp, PB_UPDATE)) {
1660
1652
                fsck_send_msg(lrdo_EXTFSWRITEFSSUPERFAIL);
1661
1653
                goto errout;
1662
1654
        }
1668
1660
         */
1669
1661
        /* read log superblock */
1670
1662
        t64 = (addressPXD(&sbp->s_logpxd) << sbp->s_l2bsize) + LOGPSIZE;
1671
 
        if (ujfs_rw_diskblocks(fd, t64, LOGPSIZE, &logsup, GET)) {
 
1663
        if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &logsup, GET)) {
1672
1664
                fsck_send_msg(lrdo_EXTFSREADLOGSUPFAIL);
1673
1665
                goto errout;
1674
1666
        }
1676
1668
        logsup.end = findEndOfLog();
1677
1669
        logsup.state = LOGREDONE;
1678
1670
 
1679
 
        if (ujfs_rw_diskblocks(fd, t64, LOGPSIZE, &logsup, PUT)) {
 
1671
        if (ujfs_rw_diskblocks(fp, t64, LOGPSIZE, &logsup, PUT)) {
1680
1672
                fsck_send_msg(lrdo_EXTFSWRITELOGSUPFAIL);
1681
1673
                goto errout;
1682
1674
        }