[FreeVMS] Re: ods2 update


Subject: [FreeVMS] Re: ods2 update
From: Patrick Caulfield (patrick@tykepenguin.com)
Date: Wed Feb 26 2003 - 16:08:36 CET


There's a bit of "long abuse" in there that I had to fix to make it work on
Alpha but with the attached patch I can read my VMS disk from Alpha-Linux !

This patch should be 32bit safe too but I' unable to test it.

-- 

patrick

-- Attached file included as plaintext by Listar --

Only in ods2: Makefile diff -u -r ods2.orig/dir.c ods2/dir.c --- ods2.orig/dir.c 2003-02-08 15:30:27.000000000 +0000 +++ ods2/dir.c 2003-02-16 15:16:34.000000000 +0000 @@ -47,15 +47,15 @@ When there are no more files to return the file position in file is set to -1. */ - + if (pos == -1) return 0; - + /* When we get called the first time for a directory file the file position is set to 0. We must then return two fake entries, . for the current directory and .. for the parent directory. */ - + if (pos == 0) { filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR); filldir(dirent, "..", 2, 1, ods2fhp->parent, DT_DIR); @@ -63,17 +63,17 @@ ods2filep->curbyte = 0; vbn = 0; } - + /* As long we can translate the virtual block number, VBN, to a logical block number, LBN, and read the block we continue to loop. */ - + while (vbn * 512 < inode->i_size && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 && (bh = bread(sb->s_dev, lbn, 512)) != NULL && bh->b_data != NULL) { short unsigned *recp = (short unsigned *)((char *)bh->b_data + (ods2filep->currec & 511)); - + /* For a ODS2 directory each block contains 1 to 62 directory entries. Note that a directory entry can not span between two or more blocks. @@ -82,11 +82,11 @@ When there are no more directory entries in the current block the record length -1 is inserted as the last record. */ - + while (*recp != 65535 && *recp <= 512 && ods2filep->currec < inode->i_size) { DIRDEF *dire = (DIRDEF *)recp; char dirname[dire->u1.s1.dir_b_namecount+1]; - + strncpy(dirname, &dire->u1.s1.dir_t_name, dire->u1.s1.dir_b_namecount); dirname[dire->u1.s1.dir_b_namecount] = 0; if (ods2p->dollar != '$' || ods2p->flags.v_lowercase) { @@ -97,14 +97,14 @@ } if (ods2filep->curbyte == 0) { ods2filep->curbyte = ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6; } filp->f_pos = ods2filep->currec + ods2filep->curbyte; - + while (ods2filep->curbyte < dire->u1.s1.dir_w_size && !(ods2p->flags.v_version != SB_M_VERSALL && strlen(dirname) == strlen(cdirname) && strncmp(dirname, cdirname, strlen(dirname)) == 0)) { DIRDEF *dirv = (DIRDEF *)((char *)dire + ods2filep->curbyte); long unsigned ino = (dirv->u1.s2.u2.s3.fid_b_nmx << 16) | dirv->u1.s2.u2.s3.fid_w_num; char dirnamev[strlen(dirname) + 1 + 5 + 1]; - + if (ino != 4) { /* we must ignore 000000.DIR as it is the same as . */ if (ods2p->flags.v_version == SB_M_VERSNONE) { sprintf(dirnamev, "%s", dirname); @@ -120,9 +120,9 @@ the false directory. */ - if (filldir(dirent, dirnamev, strlen(dirnamev), filp->f_pos, ino, + if (filldir(dirent, dirnamev, strlen(dirnamev), filp->f_pos, ino, (strstr(dirnamev, (ods2p->flags.v_lowercase ? ".dir." : ".DIR")) == NULL ? DT_REG : DT_DIR))) { - + /* We come here when filldir is unable to handle more entries. */ @@ -140,23 +140,23 @@ filp->f_pos += dire->u1.s1.dir_w_size; } } - + /* When we come here there are no more versions for the file name. We then reset our current byte offset and set current record offset to the next directory entry. */ - + ods2filep->curbyte = 0; ods2filep->currec += dire->u1.s1.dir_w_size + 2; recp = (short unsigned *)((char *)recp + dire->u1.s1.dir_w_size + 2); } - + /* When we come here there are no more directory entries in the current block and we just release the buffer and increase the VBN counter. */ - + brelse(bh); vbn++; ods2filep->currec = vbn * 512; Only in ods2.orig/: dir.o diff -u -r ods2.orig/file.c ods2/file.c --- ods2.orig/file.c 2003-02-11 00:16:30.000000000 +0000 +++ ods2/file.c 2003-02-16 15:16:18.000000000 +0000 @@ -61,7 +61,7 @@ int idxvari = IDXVARI(loff); int idxblock = IDXBLOCK(loff); ODS2VAR *ods2varp = NULL; - + if (ods2vari->ods2varp[idxvari] == NULL) { if ((ods2vari->ods2varp[idxvari] = (ODS2VAR *)kmalloc(sizeof(ODS2VAR), GFP_KERNEL)) != NULL) { memset(ods2vari->ods2varp[idxvari], 0, sizeof(ODS2VAR)); @@ -103,21 +103,21 @@ ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; ODS2VARI *ods2vari = ods2fhp->ods2vari; FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - + if (*loff == 0) { ods2filep->currec = 0; ods2filep->curbyte = 0; ods2filep->reclen = 0; } - + if (ods2filep->reclen == 65535) { brelse(ods2filep->bhp); ods2filep->bhp = NULL; return 0; } - + while (1) { - + /* We need to loop until the calculated value of currec offset plus currect byte offset from currec give the same VBN as the last one we fetched. @@ -131,23 +131,23 @@ ods2filep->reclen = 65535; return (buf - buforg); } - + /* If curbyte is zero we will start on a new record. */ - + if (ods2filep->curbyte == 0) { ods2filep->reclen = *((short unsigned *)((char *)ods2filep->bhp->b_data + (ods2filep->currec & 511))); - + if ((*loff >> 16) != 0) { down(&(ods2vari->sem)); update_virtual_file_pos(*loff, ods2vari, ods2filep->reclen); up(&(ods2vari->sem)); } - + if ((ods2filep->reclen == 65535 && !(fatp->fat_b_rattrib & FAT_M_NOSPAN)) || (ods2filep->currec > inode->i_size)) { /* end of records */ - + ods2filep->reclen = 65535; return (buf - buforg); } @@ -162,19 +162,19 @@ } } } while (((ods2filep->currec + ods2filep->curbyte) >> 9) != vbn); - + cpylen = MIN(MIN((ods2filep->reclen - ods2filep->curbyte + 2), buflen), (512 - ((ods2filep->currec + ods2filep->curbyte) & 511))); - + if (cpylen > 0) { char unsigned *recp = (char unsigned *)((char *)ods2filep->bhp->b_data + ((ods2filep->currec + ods2filep->curbyte) & 511)); - + memcpy(buf, recp, cpylen); *loff += cpylen; /* loff will always be a virtual offset for a variable record file */ buf += cpylen; buflen -= cpylen; ods2filep->curbyte += cpylen; } - + if (ods2filep->curbyte - 2 == ods2filep->reclen) { if (buflen > 0) { if (fatp->fat_b_rattrib & FAT_M_FORTRANCC || fatp->fat_b_rattrib & FAT_M_IMPLIEDCC || fatp->fat_b_rattrib & FAT_M_PRINTCC) { @@ -186,7 +186,7 @@ ods2filep->curbyte = 0; } } - + if (buflen == 0) { return (buf - buforg); } } } @@ -197,12 +197,12 @@ For a non-RMS machine that doesn't know anything about records these three formats are the same. For RMS the different between these formats is the following: - + STREAM: Records are delimited by FF, VT, LF, or CRLF. STREAMLF: Records are delimited by LF. STREAMCR: Records are delimited by CR. - - Note that we can not use generic read routines even if we treat the data as just a + + Note that we can not use generic read routines even if we treat the data as just a stream of bytes because the way we need to translate from VBN to LBN. */ @@ -212,7 +212,7 @@ short unsigned cpylen; char *buforg = buf; ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - + while (*loff < inode->i_size) { vbn = *loff >> 9; if (!(getfilebh(filp, vbn + 1))) { @@ -221,7 +221,7 @@ } if ((cpylen = MIN(MIN(inode->i_size - *loff, buflen), 512 - (*loff & 511))) > 0) { char unsigned *recp = (char unsigned *)((char *)ods2filep->bhp->b_data + (*loff & 511)); - + memcpy(buf, recp, cpylen); *loff += cpylen; buf += cpylen; @@ -235,7 +235,7 @@ ods2filep->bhp = NULL; return (buf - buforg); } - + ssize_t ods2_read(struct file *filp, char *buf, size_t buflen, loff_t *loff) { struct inode *inode = filp->f_dentry->d_inode; @@ -244,7 +244,7 @@ ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - + if (ods2p->flags.v_raw || ods2filep->u1.s1.v_raw) { return ods2_read_stream(filp, buf, buflen, loff); } else { @@ -269,7 +269,7 @@ loff_t ods2_llseek_stream(struct file *filp, loff_t loff, int seek) { struct inode *inode = filp->f_dentry->d_inode; loff_t offs; - + if (seek == 0) { /* SEEK_SET */ offs = MIN(loff, inode->i_size); } else { @@ -303,7 +303,7 @@ ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); short unsigned reclen = 0; - + offs = loff; if (seek == 0) { /* SEEK_SET */ offs = MIN(offs, inode->i_size); @@ -318,14 +318,14 @@ offs = MIN(inode->i_size + offs, inode->i_size); } } - + /* offs - the absolute virtual offset into the file we want to find. coffs - offset counter. */ - + down(&(ods2vari->sem)); - + if (offs > 65535) { coffs = offs; if ((coffs >> 16) > (ods2vari->highidx >> 16)) { @@ -347,9 +347,9 @@ coffs = 0; } } - + while (1) { - + do { vbn = currec >> 9; if (!(getfilebh(filp, vbn + 1))) { @@ -361,7 +361,7 @@ return offs; } reclen = *((short unsigned *)((char *)ods2filep->bhp->b_data + (currec & 511))); - + if ((reclen == 65535 && !(fatp->fat_b_rattrib & FAT_M_NOSPAN)) || currec > inode->i_size) { /* end of records */ ods2filep->reclen = 65535; up(&(ods2vari->sem)); @@ -374,7 +374,7 @@ currec = (vbn + 1) * 512; /* next block... */ } } while (reclen == 65535); - + if (coffs <= offs && (coffs + reclen) >= offs) { /* we have found our location */ ods2filep->currec = currec; ods2filep->curbyte = (offs - coffs) + 2; @@ -388,7 +388,7 @@ filp->f_version++; return offs; } - + if (fatp->fat_b_rattrib & FAT_M_FORTRANCC || fatp->fat_b_rattrib & FAT_M_IMPLIEDCC || fatp->fat_b_rattrib & FAT_M_PRINTCC) { coffs += reclen + 1; /* need to add one byte for LF */ } @@ -400,7 +400,7 @@ } } - + loff_t ods2_llseek(struct file *filp, loff_t loff, int seek) { struct inode *inode = filp->f_dentry->d_inode; struct super_block *sb = inode->i_sb; @@ -408,7 +408,7 @@ ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; FATDEF *fatp = (FATDEF *)&(ods2fhp->fat); - + if (ods2p->flags.v_raw || ods2filep->u1.s1.v_raw) { return ods2_llseek_stream(filp, loff, seek); } else { @@ -435,7 +435,7 @@ } } else { ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - + if (ods2filep != NULL) { brelse(ods2filep->bhp); kfree(filp->private_data); Only in ods2.orig/: file.o diff -u -r ods2.orig/inode.c ods2/inode.c --- ods2.orig/inode.c 2003-02-08 18:14:04.000000000 +0000 +++ ods2/inode.c 2003-02-26 15:01:21.000000000 +0000 @@ -71,17 +71,17 @@ char *vp; short unsigned *rec; ODS2FH *ods2fhp = (ODS2FH *)dir->u.generic_ip; - + strncpy(name, dentry->d_name.name, dentry->d_name.len); name[dentry->d_name.len] = 0; - + /* We need to extract any version number and terminate the file name with file type at the ; character because in the directory file only the file name and type is stored as text without the ; character. The version number for the file is stored together with each FID. */ - + if (( vp = strrchr(name, ods2p->semicolon)) != NULL) { *vp++ = 0; if (sscanf(vp, "%d", &vers) != 1) { @@ -91,36 +91,36 @@ return ERR_PTR(-EBADF); } } - + while ((lbn = vbn2lbn(sb, ods2fhp->map, vbn)) > 0 && (bh = bread(sb->s_dev, lbn, 512)) != NULL && bh->b_data != NULL) { - + rec = (short unsigned *)bh->b_data; - + while (*rec != 65535 && *rec != 0) { DIRDEF *dire = (DIRDEF *)rec; - + if (dire->u1.s1.dir_b_namecount == strlen(name)) { char dirname[dire->u1.s1.dir_b_namecount+1]; - + strncpy(dirname, &dire->u1.s1.dir_t_name, dire->u1.s1.dir_b_namecount); dirname[dire->u1.s1.dir_b_namecount] = 0; if (ods2p->dollar != '$' || ods2p->flags.v_lowercase) { char *p = dirname; char cnt = dire->u1.s1.dir_b_namecount; - + while (*p && cnt-- > 0) { if (*p == '$') { *p = ods2p->dollar; } if (ods2p->flags.v_lowercase) { *p = tolower(*p); } p++; } } if (strcmp(dirname, name) == 0) { int curbyte = 0; - + while (curbyte < dire->u1.s1.dir_w_size) { long unsigned ino; DIRDEF *dirv = (DIRDEF *)((char *)dire + ((dire->u1.s1.dir_b_namecount + 1) & ~1) + 6 + curbyte); - + if (dirv->u1.s2.dir_w_version == vers || vers == 0) { struct inode *inode; - + ino = (dirv->u1.s2.u2.s3.fid_b_nmx << 16) | dirv->u1.s2.u2.s3.fid_w_num; brelse(bh); if ((inode = iget(dir->i_sb, ino)) != NULL) { @@ -213,7 +213,7 @@ and after a while the kernel will start to stop processes to release physical memory. */ - + printk("ODS2-fs buffer cache and/or slab bug\n"); lock_buffer(bh); clear_bit(BH_Uptodate, &bh->b_state); @@ -239,25 +239,25 @@ } inode->i_uid = le16_to_cpu(fh2p->u5.s1.fh2_w_mem); inode->i_gid = le16_to_cpu(fh2p->u5.s1.fh2_w_grp); - + inode->i_ctime = vms2unixtime(fi2p->fi2_q_credate); inode->i_mtime = vms2unixtime(fi2p->fi2_q_revdate); inode->i_atime = vms2unixtime(fi2p->fi2_q_revdate); - + /* Note that we don't use the system protection bits for ODS2. */ - + inode->i_mode |= vms2unixprot[(le16_to_cpu(fh2p->fh2_w_fileprot) >> 4) & 0x0f] << 6; /* owner */ inode->i_mode |= vms2unixprot[(le16_to_cpu(fh2p->fh2_w_fileprot) >> 8) & 0x0f] << 3; /* group */ inode->i_mode |= vms2unixprot[(le16_to_cpu(fh2p->fh2_w_fileprot) >> 12) & 0x0f]; /* world => other */ - + inode->i_blksize = 512; inode->i_blocks = ((le16_to_cpu(fatp->u1.s1.fat_w_hiblkh) << 16) | le16_to_cpu(fatp->u1.s1.fat_w_hiblkl)); inode->i_size = ((le16_to_cpu(fatp->u2.s1.fat_w_efblkh) << 16) | le16_to_cpu(fatp->u2.s1.fat_w_efblkl)) * 512; if (inode->i_size > 0) { inode->i_size -= 512; } inode->i_size += le16_to_cpu(fatp->fat_w_ffbyte); - + if ((fatp->u0.s0.fat_v_rtype == FAT_C_VFC || fatp->u0.s0.fat_v_rtype == FAT_C_VARIABLE) && !ods2p->flags.v_raw) { if ((ods2fhp->ods2vari = (ODS2VARI *)kmalloc(sizeof(ODS2VARI), GFP_KERNEL)) != NULL) { memset(ods2fhp->ods2vari, 0 , sizeof(ODS2VARI)); @@ -266,7 +266,7 @@ printk("ODS2-fs kmalloc failed for vari data\n"); } } - + ods2fhp->parent = (fh2p->u6.s1.fid_b_nmx << 16) | le16_to_cpu(fh2p->u6.s1.fid_w_num); inode->i_version = ++event; bforget(bh); @@ -293,27 +293,27 @@ void ods2_clear_inode(struct inode *inode) { ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; - + if (ods2fhp != NULL) { ODS2MAP *map = ods2fhp->map; - + while (map != NULL) { ODS2MAP *nxt = map->nxt; - + kfree(map); map = nxt; } ods2fhp->map = NULL; - + if (ods2fhp->ods2vari != NULL) { /* in case the file was of variable record type */ int idx; - + for (idx = 0; idx < 128; idx++) { ODS2VAR *ods2varp = ods2fhp->ods2vari->ods2varp[idx]; - + while (ods2varp != NULL) { ODS2VAR *nxt = ods2varp->nxt; - + kfree(ods2varp); ods2varp = nxt; } Only in ods2.orig/: inode.o diff -u -r ods2.orig/ods2.h ods2/ods2.h --- ods2.orig/ods2.h 2003-02-09 03:03:06.000000000 +0000 +++ ods2/ods2.h 2003-02-16 15:17:18.000000000 +0000 @@ -21,9 +21,9 @@ */ typedef struct hm2def { - long unsigned hm2_l_homelbn; - long unsigned hm2_l_alhomelbn; - long unsigned hm2_l_altidxlbn; + uint32_t hm2_l_homelbn; + uint32_t hm2_l_alhomelbn; + uint32_t hm2_l_altidxlbn; union { short unsigned hm2_w_struclev; struct { @@ -36,8 +36,8 @@ short unsigned hm2_w_alhomevbn; short unsigned hm2_w_altidxvbn; short unsigned hm2_w_ibmapvbn; - long unsigned hm2_l_ibmaplbn; - long unsigned hm2_l_maxfiles; + uint32_t hm2_l_ibmaplbn; + uint32_t hm2_l_maxfiles; short unsigned hm2_w_ibmapsize; short unsigned hm2_w_resfiles; short unsigned hm2_w_devtype; @@ -45,28 +45,28 @@ short unsigned hm2_w_setcount; short unsigned hm2_w_volchar; union { - long unsigned hm2_l_owner; + uint32_t hm2_l_owner; struct { short unsigned hm2_w_mem; short unsigned hm2_w_grp; } s1; } u2; - long unsigned hm2_l_res1; + uint32_t hm2_l_res1; short unsigned hm2_w_protect; short unsigned hm2_w_fileprot; short unsigned hm2_w_res2; short unsigned hm2_w_checksum1; - long unsigned hm2_q_credate[2]; + uint32_t hm2_q_credate[2]; char unsigned hm2_b_window; char unsigned hm2_b_lru_lim; short unsigned hm2_w_extend; - long unsigned hm2_q_retainmin[2]; - long unsigned hm2_q_retainmax[2]; - long unsigned hm2_q_revdate[2]; + uint32_t hm2_q_retainmin[2]; + uint32_t hm2_q_retainmax[2]; + uint32_t hm2_q_revdate[2]; char unsigned hm2_r_min_class[20]; char unsigned hm2_r_max_class[20]; char unsigned hm2_b_res3[320]; - long unsigned hm2_l_serialnum; + uint32_t hm2_l_serialnum; char hm2_t_structname[12]; char hm2_t_volname[12]; char hm2_t_ownername[12]; @@ -89,38 +89,38 @@ } s1; } u1; short unsigned scb_w_cluster; - long unsigned scb_l_volsize; - long unsigned scb_l_blksize; - long unsigned scb_l_sectors; - long unsigned scb_l_tracks; - long unsigned scb_l_cylinders; - union { - long unsigned scb_l_status; - struct { - long unsigned scb_v_mapdirty:1; - long unsigned scb_v_mapalloc:1; - long unsigned scb_v_filalloc:1; - long unsigned scb_v_quodirty:1; - long unsigned scb_v_hdrwrite:1; - long unsigned scb_v_corrupt:1; + uint32_t scb_l_volsize; + uint32_t scb_l_blksize; + uint32_t scb_l_sectors; + uint32_t scb_l_tracks; + uint32_t scb_l_cylinders; + union { + uint32_t scb_l_status; + struct { + uint32_t scb_v_mapdirty:1; + uint32_t scb_v_mapalloc:1; + uint32_t scb_v_filalloc:1; + uint32_t scb_v_quodirty:1; + uint32_t scb_v_hdrwrite:1; + uint32_t scb_v_corrupt:1; } s1; } u2; union { - long unsigned scb_l_status2; + uint32_t scb_l_status2; struct { - long unsigned scb_v_mapdirty:1; - long unsigned scb_v_mapalloc:1; - long unsigned scb_v_filalloc:1; - long unsigned scb_v_quodirty:1; - long unsigned scb_v_hdrwrite:1; - long unsigned scb_v_corrupt:1; + uint32_t scb_v_mapdirty:1; + uint32_t scb_v_mapalloc:1; + uint32_t scb_v_filalloc:1; + uint32_t scb_v_quodirty:1; + uint32_t scb_v_hdrwrite:1; + uint32_t scb_v_corrupt:1; } s1; } u3; short unsigned scb_w_writecnt; char scb_t_volockname[12]; short unsigned scb_q_mounttime[4]; short unsigned scb_w_backrev; - long long unsigned scb_q_genernum; + uint64_t scb_q_genernum; char unsigned scb_b_reserved[446]; short unsigned scb_w_checksum; } SCBDEF; @@ -176,33 +176,33 @@ char unsigned fid_b_ex_fidnmx; } s1; } u3; - long unsigned fh2_w_recattr[8]; + uint32_t fh2_w_recattr[8]; union { struct filechar { - long unsigned fch_v_wascontig:1; - long unsigned fch_v_nobackup:1; - long unsigned fch_v_writeback:1; - long unsigned fch_v_readcheck:1; - long unsigned fch_v_writecheck:1; - long unsigned fch_v_contigb:1; - long unsigned fch_v_locked:1; - long unsigned fch_v_contig:1; - long unsigned fch_v_res1:3; - long unsigned fch_v_badacl:1; - long unsigned fch_v_spool:1; - long unsigned fch_v_directory:1; - long unsigned fch_v_badblock:1; - long unsigned fch_v_markdel:1; - long unsigned fch_v_nocharge:1; - long unsigned fch_v_erase:1; + uint32_t fch_v_wascontig:1; + uint32_t fch_v_nobackup:1; + uint32_t fch_v_writeback:1; + uint32_t fch_v_readcheck:1; + uint32_t fch_v_writecheck:1; + uint32_t fch_v_contigb:1; + uint32_t fch_v_locked:1; + uint32_t fch_v_contig:1; + uint32_t fch_v_res1:3; + uint32_t fch_v_badacl:1; + uint32_t fch_v_spool:1; + uint32_t fch_v_directory:1; + uint32_t fch_v_badblock:1; + uint32_t fch_v_markdel:1; + uint32_t fch_v_nocharge:1; + uint32_t fch_v_erase:1; } s1; - long unsigned fh2_l_filechar; + uint32_t fh2_l_filechar; } u4; short unsigned fh2_w_res1; char unsigned fh2_b_map_inuse; char unsigned fh2_b_acc_mode; union { - long unsigned fh2_l_fileowner; + uint32_t fh2_l_fileowner; struct { short unsigned fh2_w_mem; short unsigned fh2_w_grp; @@ -221,7 +221,7 @@ char unsigned fh2_b_journal; char unsigned fh2_b_ru_active; short unsigned fh2_w_res2; - long unsigned fh2_l_highwater; + uint32_t fh2_l_highwater; char unsigned fh2_b_res3[8]; char unsigned fh2_r_class_prot[20]; char unsigned fh2_b_res4[402]; @@ -264,14 +264,14 @@ char unsigned fat_b_rattrib; char unsigned fat_w_rsize; union { - long unsigned fat_l_hiblk; + uint32_t fat_l_hiblk; struct { short unsigned fat_w_hiblkh; short unsigned fat_w_hiblkl; } s1; } u1; union { - long unsigned fat_l_efblk; + uint32_t fat_l_efblk; struct { short unsigned fat_w_efblkh; short unsigned fat_w_efblkl; @@ -310,7 +310,7 @@ short unsigned fm2_v_count2:14; short unsigned fm2_v_format:2; short unsigned fm2_w_lowcount; - long unsigned fm2_l_lbn3; + uint32_t fm2_l_lbn3; } fm3; } u1; } FM2DEF; @@ -363,8 +363,8 @@ typedef struct ods2map { struct ods2map *nxt; struct { - unsigned long cnt; - unsigned long lbn; + uint32_t cnt; + uint32_t lbn; } s1[16]; } ODS2MAP; @@ -417,14 +417,14 @@ typedef struct ods2file { struct buffer_head *bhp; - long long unsigned currec; /* byte offset to current record --- from start of file */ + uint64_t currec; /* byte offset to current record --- from start of file */ short unsigned curbyte; /* byte offset into current record */ short unsigned reclen; /* length of current record */ union { - long unsigned flags; + uint32_t flags; struct { - long unsigned v_raw:1; /* this file handler must return data in raw mode */ - long unsigned v_res1:31; + uint32_t v_raw:1; /* this file handler must return data in raw mode */ + uint32_t v_res1:31; } s1; } u1; } ODS2FILE; @@ -438,7 +438,7 @@ ODS2MAP *map; /* mapping information from VBN to LBN */ ODS2VARI *ods2vari; /* only used for variable record files */ FATDEF fat; /* file attributes */ - long unsigned parent; /* ino of parent directory */ + uint32_t parent; /* ino of parent directory */ } ODS2FH; /* @@ -487,18 +487,18 @@ as well as for files created 1992 and 2003. */ -#define vms2unixtime(a) ((unsigned long)div64((le64_to_cpu(*(long long unsigned *)&(a)) - 0x007c953d63a19980L) >> 7, 78125) + 2); +#define vms2unixtime(a) ((uint32_t)div64((le64_to_cpu(*(uint64_t *)&(a)) - 0x007c953d63a19980L) >> 7, 78125) + 2); /* util.c */ -unsigned long long div64(unsigned long long a, unsigned long b0); -unsigned long vbn2lbn(struct super_block *sb, ODS2MAP *map, unsigned long vbn); -unsigned long ino2fhlbn(struct super_block *sb, unsigned long ino); +uint64_t div64(uint64_t a, uint32_t b0); +uint32_t vbn2lbn(struct super_block *sb, ODS2MAP *map, uint32_t vbn); +unsigned long ino2fhlbn(struct super_block *sb, uint32_t ino); ODS2MAP *getmap(struct super_block *sb, FH2DEF *fh2p); -struct buffer_head *getfilebh(struct file *filp, long unsigned vbn); -int verify_fh(FH2DEF *fh2p, long unsigned ino); +struct buffer_head *getfilebh(struct file *filp, uint32_t vbn); +int verify_fh(FH2DEF *fh2p, uint32_t ino); int parse_options(struct super_block *sb, char *options); /* @@ -521,7 +521,7 @@ file.c */ -int ods2_file_ioctl(struct inode *inode, struct file *filp, int unsigned cmd, long unsigned arg); +int ods2_file_ioctl(struct inode *inode, struct file *filp, int unsigned cmd, unsigned long arg); ssize_t ods2_read(struct file *filp, char *buf, size_t buflen, loff_t *loff); loff_t ods2_llseek(struct file *filp, loff_t loff, int seek); int ods2_open_release(struct inode *inode, struct file *filp); Only in ods2.orig/: ods2.o diff -u -r ods2.orig/super.c ods2/super.c --- ods2.orig/super.c 2003-02-08 15:43:57.000000000 +0000 +++ ods2/super.c 2003-02-26 15:01:37.000000000 +0000 @@ -31,7 +31,7 @@ static void ods2_put_super(struct super_block *sb) { ODS2SB *ods2p = (ODS2SB *)sb->u.generic_sbp; - + if (ods2p != NULL) { iput(ods2p->indexf); /* release INDEXF.SYS;1 */ kfree(ods2p->ibitmap); @@ -47,7 +47,7 @@ static int ods2_statfs(struct super_block *sb, struct statfs *buf) { ODS2SB *ods2p = (ODS2SB *)sb->u.generic_sbp; - + memcpy(buf, &ods2p->statfs, sizeof(struct statfs)); return 0; } @@ -80,28 +80,28 @@ ODS2SB *ods2p = (ODS2SB *)sb->u.generic_sbp; struct buffer_head *bh; struct inode *inode; - + if ((inode = iget(sb, 2)) != NULL) { /* this is BITMAP.SYS */ ODS2FH *ods2fhp = (ODS2FH *)(inode->u.generic_ip); long unsigned lbn; if ((lbn = vbn2lbn(sb, ods2fhp->map, 1)) > 0 && (bh = bread(sb->s_dev, lbn, 512)) != NULL && bh->b_data != NULL) { - + short unsigned chksum = 0; struct scbdef *scb = (SCBDEF *)(bh->b_data); short unsigned *p; - + for (p = (short unsigned *)scb ; p < (short unsigned *)&(scb->scb_w_checksum) ; chksum += *p++); - + if (scb->u1.s1.scb_b_structlevl == 2 && scb->u1.s1.scb_b_structlevv >= 1 && scb->scb_w_cluster == ods2p->hm2.hm2_w_cluster && scb->scb_w_checksum == chksum) { - + int vbn = 1; long unsigned bitset = 0; struct buffer_head *bh2; - + /* We need to loop through all bytes that make up the bitmap. The fastest way to count the number of bits set in the byte @@ -112,10 +112,10 @@ while (vbn * 512 < inode->i_size && (lbn = vbn2lbn(sb, ods2fhp->map, vbn + 1)) > 0 && (bh2 = bread(sb->s_dev, lbn, 512)) != NULL && bh->b_data != NULL) { - + char unsigned *bp = (char unsigned *)bh2->b_data; int cnt; - + for (cnt = 0; cnt < 512; cnt++, bp++) { bitset += (nibble2bits[*bp & 0x0f] + nibble2bits[*bp >> 4]); } brelse(bh2); vbn++; @@ -169,7 +169,7 @@ This is the routine that is invoked when an ODS2 file system is mounted. */ - + static struct super_block * ods2_read_super(struct super_block *sb, void *data, int silent) { struct buffer_head *bh; ODS2SB *ods2p; @@ -180,7 +180,7 @@ short unsigned chksum1 = 0; short unsigned chksum2 = 0; short unsigned *p; - + if ((sb->u.generic_sbp = kmalloc(sizeof(ODS2SB), GFP_KERNEL)) == NULL) { printk("ODS2-fs kmalloc failed for sb generic\n"); return NULL; @@ -188,7 +188,7 @@ ods2p = (ODS2SB *)sb->u.generic_sbp; memcpy(&ods2p->hm2, bh->b_data, sizeof(HM2DEF)); brelse(bh); - + for (p = (short unsigned *)&(ods2p->hm2) ; p < (short unsigned *)&(ods2p->hm2.hm2_w_checksum1) ; chksum1 += *p++); for (p = (short unsigned *)&(ods2p->hm2) ; p < (short unsigned *)&(ods2p->hm2.hm2_w_checksum2) ; chksum2 += *p++); @@ -202,7 +202,7 @@ ods2p->hm2.hm2_w_homevbn != 0 && ods2p->hm2.hm2_l_ibmaplbn != 0 && ods2p->hm2.hm2_l_maxfiles > ods2p->hm2.hm2_w_resfiles && ods2p->hm2.hm2_w_resfiles >= 5 && chksum1 == ods2p->hm2.hm2_w_checksum1 && chksum2 == ods2p->hm2.hm2_w_checksum2) { - + ods2p->flags.v_raw = 0; ods2p->flags.v_version = SB_M_VERSALL; @@ -211,39 +211,39 @@ if (data != NULL) { parse_options(sb, data); } sb->s_op = &ods2_sops; - + ods2p->indexf = iget(sb, 1); /* read INDEXF.SYS. */ - + sb->s_root = d_alloc_root(iget(sb, 4)); /* this is 000000.DIR;1 */ - + /* We need to be able to read the index file header bitmap. */ if (ods2_read_ibitmap(sb)) { - + /* We need to be able to read BITMAP.SYS as it contains the bitmap for allocated blocks. Without this file we need to rebuild it by reading ALL file mapping pointers for ALL files and create the file. That will be in a later release... */ - + if (ods2_read_bitmap(sb)) { char format[13]; char volname[13]; char volowner[13]; - + /* We need to fill in statfs structure used when any user want to get information about the mounted ODS2 file system. Some of the information is static and other is found in BITMAP.SYS. */ - + ods2p->statfs.f_type = 0x3253444f; /* 2SDO */ ods2p->statfs.f_bsize = 512; ods2p->statfs.f_files = ods2p->hm2.hm2_l_maxfiles; ods2p->statfs.f_namelen = 80; - + strncpy(format, ods2p->hm2.hm2_t_format, 12); format[12] = 0; strncpy(volname, ods2p->hm2.hm2_t_volname, 12); Only in ods2.orig/: super.o Only in ods2.orig/: tparse.o diff -u -r ods2.orig/util.c ods2/util.c --- ods2.orig/util.c 2003-02-10 21:13:43.000000000 +0000 +++ ods2/util.c 2003-02-26 15:01:56.000000000 +0000 @@ -25,26 +25,26 @@ #include "tparse.h" -unsigned long long div64(unsigned long long a, unsigned long b0) { +uint64_t div64(uint64_t a, uint32_t b0) { unsigned int a1, a2; - unsigned long long res; - + uint64_t res; + a1 = ((unsigned int*)&a)[0]; a2 = ((unsigned int*)&a)[1]; - + res = a1/b0 + (unsigned long long)a2 * (unsigned long long)(0xffffffff/b0) + a2 / b0 + (a2 * (0xffffffff % b0)) / b0; - + return res; } -unsigned long vbn2lbn(struct super_block *sb, ODS2MAP *map, unsigned long vbn) { +uint32_t vbn2lbn(struct super_block *sb, ODS2MAP *map, uint32_t vbn) { int idx = 0; long unsigned curvbn = 1; /* VBN is 1 based - not 0 */ - + while (map && map->s1[idx].cnt > 0 && curvbn < vbn && curvbn + map->s1[idx].cnt <= vbn) { curvbn += map->s1[idx].cnt; if (++idx > 15) { @@ -59,14 +59,14 @@ } -unsigned long ino2fhlbn(struct super_block *sb, unsigned long ino) { +unsigned long ino2fhlbn(struct super_block *sb, uint32_t ino) { ODS2SB *ods2p = (ODS2SB *)sb->u.generic_sbp; - + if (ino < 17) { /* the first 16 file headers are located at known locations in INDEXF.SYS */ return ods2p->hm2.hm2_w_ibmapsize + ods2p->hm2.hm2_l_ibmaplbn + ino - 1; } else { ODS2FH *ods2fhp = (ODS2FH *)ods2p->indexf->u.generic_ip; - + return vbn2lbn(sb, ods2fhp->map, ods2p->hm2.hm2_w_cluster * 4 + ods2p->hm2.hm2_w_ibmapsize + ino); } return 0; @@ -99,7 +99,7 @@ long unsigned cnt = 0; long unsigned lbn = 0; short unsigned size = 0; - + switch (fm2p->u1.fm1.fm2_v_format) { case 0: size = 1; break; case 1: cnt = fm2p->u1.fm1.fm2_b_count1; lbn = (fm2p->u1.fm1.fm2_v_highlbn << 16) | fm2p->u1.fm1.fm2_w_lowlbn; size = 2; break; @@ -124,19 +124,19 @@ mapinuse -= size; fm2p = (FM2DEF *)((short unsigned *)(fm2p) + size); } - + /* If there is an extension header we need to read all of them because they could have additional mapping information. - + Note that we can not use iget to fetch the extension header because it is not a valid inode for an ODS2 file. Only primary file header can be used as an inode. */ - + if (fh2p->u3.s1.fid_w_ex_fidnum != 0) { long unsigned lbn; - + if ((lbn = ino2fhlbn(sb, fh2p->u3.s1.fid_w_ex_fidnum | (fh2p->u3.s1.fid_b_ex_fidnmx << 16))) != 0) { fh2p = NULL; brelse(bh); @@ -154,12 +154,12 @@ } -struct buffer_head *getfilebh(struct file *filp, long unsigned vbn) { +struct buffer_head *getfilebh(struct file *filp, uint32_t vbn) { struct inode *inode = filp->f_dentry->d_inode; struct super_block *sb = inode->i_sb; ODS2FH *ods2fhp = (ODS2FH *)inode->u.generic_ip; ODS2FILE *ods2filep = (ODS2FILE *)filp->private_data; - + if ((vbn - 1) * 512 < inode->i_size) { long unsigned lbn; @@ -183,7 +183,7 @@ } -int verify_fh(FH2DEF *fh2p, long unsigned ino) { +int verify_fh(FH2DEF *fh2p, uint32_t ino) { short unsigned *p = (short unsigned *)fh2p; short unsigned chksum = 0; Only in ods2.orig/: util.o

-- Liste de diffusion FreeVMS Pour se dťsinscrire : mailto:freevms-request@ml.free.fr?subject=unsubscribe



This archive was generated by hypermail 2b25 : Wed Feb 26 2003 - 16:11:12 CET