patch-2.4.19 linux-2.4.19/fs/udf/misc.c
Next file: linux-2.4.19/fs/udf/namei.c
Previous file: linux-2.4.19/fs/udf/lowlevel.c
Back to the patch index
Back to the overall index
- Lines: 452
- Date:
Fri Aug 2 17:39:45 2002
- Orig file:
linux-2.4.18/fs/udf/misc.c
- Orig date:
Mon Feb 25 11:38:09 2002
diff -urN linux-2.4.18/fs/udf/misc.c linux-2.4.19/fs/udf/misc.c
@@ -16,7 +16,7 @@
* Each contributing author retains all rights to their own work.
*
* (C) 1998 Dave Boynton
- * (C) 1998-2000 Ben Fennema
+ * (C) 1998-2001 Ben Fennema
* (C) 1999-2000 Stelias Computing Inc
*
* HISTORY
@@ -26,46 +26,25 @@
#include "udfdecl.h"
-#if defined(__linux__) && defined(__KERNEL__)
-
-#include "udf_sb.h"
-#include "udf_i.h"
-
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/udf_fs.h>
-#else
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-int udf_blocksize=0;
-int udf_errno=0;
-
-void
-udf_setblocksize(int size)
-{
- udf_blocksize=size;
-}
-#endif
+#include "udf_i.h"
+#include "udf_sb.h"
-Uint32
-udf64_low32(Uint64 indat)
+uint32_t
+udf64_low32(uint64_t indat)
{
return indat & 0x00000000FFFFFFFFULL;
}
-Uint32
-udf64_high32(Uint64 indat)
+uint32_t
+udf64_high32(uint64_t indat)
{
return indat >> 32;
}
-#if defined(__linux__) && defined(__KERNEL__)
-
extern struct buffer_head *
udf_tgetblk(struct super_block *sb, int block)
{
@@ -84,11 +63,11 @@
return sb_bread(sb, block);
}
-extern struct GenericAttrFormat *
-udf_add_extendedattr(struct inode * inode, Uint32 size, Uint32 type,
- Uint8 loc, struct buffer_head **bh)
+extern struct genericFormat *
+udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
+ uint8_t loc, struct buffer_head **bh)
{
- Uint8 *ea = NULL, *ad = NULL;
+ uint8_t *ea = NULL, *ad = NULL;
long_ad eaicb;
int offset;
@@ -96,26 +75,26 @@
if (UDF_I_EXTENDED_FE(inode) == 0)
{
- struct FileEntry *fe;
+ struct fileEntry *fe;
- fe = (struct FileEntry *)(*bh)->b_data;
+ fe = (struct fileEntry *)(*bh)->b_data;
eaicb = lela_to_cpu(fe->extendedAttrICB);
- offset = sizeof(struct FileEntry);
+ offset = sizeof(struct fileEntry);
}
else
{
- struct ExtendedFileEntry *efe;
+ struct extendedFileEntry *efe;
- efe = (struct ExtendedFileEntry *)(*bh)->b_data;
+ efe = (struct extendedFileEntry *)(*bh)->b_data;
eaicb = lela_to_cpu(efe->extendedAttrICB);
- offset = sizeof(struct ExtendedFileEntry);
+ offset = sizeof(struct extendedFileEntry);
}
ea = &(*bh)->b_data[offset];
if (UDF_I_LENEATTR(inode))
offset += UDF_I_LENEATTR(inode);
else
- size += sizeof(struct ExtendedAttrHeaderDesc);
+ size += sizeof(struct extendedAttrHeaderDesc);
ad = &(*bh)->b_data[offset];
if (UDF_I_LENALLOC(inode))
@@ -127,8 +106,8 @@
if (loc & 0x01 && offset >= size)
{
- struct ExtendedAttrHeaderDesc *eahd;
- eahd = (struct ExtendedAttrHeaderDesc *)ea;
+ struct extendedAttrHeaderDesc *eahd;
+ eahd = (struct extendedAttrHeaderDesc *)ea;
if (UDF_I_LENALLOC(inode))
{
@@ -138,7 +117,7 @@
if (UDF_I_LENEATTR(inode))
{
/* check checksum/crc */
- if (le16_to_cpu(eahd->descTag.tagIdent) != TID_EXTENDED_ATTRE_HEADER_DESC ||
+ if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum)
{
udf_release_data(*bh);
@@ -147,9 +126,9 @@
}
else
{
- size -= sizeof(struct ExtendedAttrHeaderDesc);
- UDF_I_LENEATTR(inode) += sizeof(struct ExtendedAttrHeaderDesc);
- eahd->descTag.tagIdent = cpu_to_le16(TID_EXTENDED_ATTRE_HEADER_DESC);
+ size -= sizeof(struct extendedAttrHeaderDesc);
+ UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
+ eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
eahd->descTag.descVersion = cpu_to_le16(2);
eahd->descTag.tagSerialNum = cpu_to_le16(1);
eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
@@ -162,7 +141,7 @@
{
if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode))
{
- Uint32 aal = le32_to_cpu(eahd->appAttrLocation);
+ uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
memmove(&ea[offset - aal + size],
&ea[aal], offset - aal);
offset -= aal;
@@ -170,7 +149,7 @@
}
if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode))
{
- Uint32 ial = le32_to_cpu(eahd->impAttrLocation);
+ uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
memmove(&ea[offset - ial + size],
&ea[ial], offset - ial);
offset -= ial;
@@ -181,7 +160,7 @@
{
if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode))
{
- Uint32 aal = le32_to_cpu(eahd->appAttrLocation);
+ uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
memmove(&ea[offset - aal + size],
&ea[aal], offset - aal);
offset -= aal;
@@ -190,7 +169,7 @@
}
/* rewrite CRC + checksum of eahd */
UDF_I_LENEATTR(inode) += size;
- return (struct GenericAttrFormat *)&ea[offset];
+ return (struct genericFormat *)&ea[offset];
}
if (loc & 0x02)
{
@@ -199,31 +178,31 @@
return NULL;
}
-extern struct GenericAttrFormat *
-udf_get_extendedattr(struct inode * inode, Uint32 type, Uint8 subtype,
+extern struct genericFormat *
+udf_get_extendedattr(struct inode * inode, uint32_t type, uint8_t subtype,
struct buffer_head **bh)
{
- struct GenericAttrFormat *gaf;
- Uint8 *ea = NULL;
+ struct genericFormat *gaf;
+ uint8_t *ea = NULL;
long_ad eaicb;
- Uint32 offset;
+ uint32_t offset;
*bh = udf_tread(inode->i_sb, inode->i_ino);
if (UDF_I_EXTENDED_FE(inode) == 0)
{
- struct FileEntry *fe;
+ struct fileEntry *fe;
- fe = (struct FileEntry *)(*bh)->b_data;
+ fe = (struct fileEntry *)(*bh)->b_data;
eaicb = lela_to_cpu(fe->extendedAttrICB);
if (UDF_I_LENEATTR(inode))
ea = fe->extendedAttr;
}
else
{
- struct ExtendedFileEntry *efe;
+ struct extendedFileEntry *efe;
- efe = (struct ExtendedFileEntry *)(*bh)->b_data;
+ efe = (struct extendedFileEntry *)(*bh)->b_data;
eaicb = lela_to_cpu(efe->extendedAttrICB);
if (UDF_I_LENEATTR(inode))
ea = efe->extendedAttr;
@@ -231,11 +210,11 @@
if (UDF_I_LENEATTR(inode))
{
- struct ExtendedAttrHeaderDesc *eahd;
- eahd = (struct ExtendedAttrHeaderDesc *)ea;
+ struct extendedAttrHeaderDesc *eahd;
+ eahd = (struct extendedAttrHeaderDesc *)ea;
/* check checksum/crc */
- if (le16_to_cpu(eahd->descTag.tagIdent) != TID_EXTENDED_ATTRE_HEADER_DESC ||
+ if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum)
{
udf_release_data(*bh);
@@ -243,7 +222,7 @@
}
if (type < 2048)
- offset = sizeof(struct ExtendedAttrHeaderDesc);
+ offset = sizeof(struct extendedAttrHeaderDesc);
else if (type < 65536)
offset = le32_to_cpu(eahd->impAttrLocation);
else
@@ -251,7 +230,7 @@
while (offset < UDF_I_LENEATTR(inode))
{
- gaf = (struct GenericAttrFormat *)&ea[offset];
+ gaf = (struct genericFormat *)&ea[offset];
if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
return gaf;
else
@@ -267,22 +246,6 @@
return NULL;
}
-extern struct buffer_head *
-udf_read_untagged(struct super_block *sb, Uint32 block, Uint32 offset)
-{
- struct buffer_head *bh = NULL;
-
- /* Read the block */
- bh = udf_tread(sb, block+offset);
- if (!bh)
- {
- printk(KERN_ERR "udf: udf_read_untagged(%p,%d,%d) failed\n",
- sb, block, offset);
- return NULL;
- }
- return bh;
-}
-
/*
* udf_read_tagged
*
@@ -294,11 +257,11 @@
* Written, tested, and released.
*/
extern struct buffer_head *
-udf_read_tagged(struct super_block *sb, Uint32 block, Uint32 location, Uint16 *ident)
+udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint16_t *ident)
{
tag *tag_p;
struct buffer_head *bh = NULL;
- register Uint8 checksum;
+ register uint8_t checksum;
register int i;
/* Read the block */
@@ -326,9 +289,9 @@
/* Verify the tag checksum */
checksum = 0U;
for (i = 0; i < 4; i++)
- checksum += (Uint8)(bh->b_data[i]);
+ checksum += (uint8_t)(bh->b_data[i]);
for (i = 5; i < 16; i++)
- checksum += (Uint8)(bh->b_data[i]);
+ checksum += (uint8_t)(bh->b_data[i]);
if (checksum != tag_p->tagChecksum) {
printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
goto error_out;
@@ -359,7 +322,7 @@
}
extern struct buffer_head *
-udf_read_ptagged(struct super_block *sb, lb_addr loc, Uint32 offset, Uint16 *ident)
+udf_read_ptagged(struct super_block *sb, lb_addr loc, uint32_t offset, uint16_t *ident)
{
return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset),
loc.logicalBlockNum + offset, ident);
@@ -371,8 +334,6 @@
brelse(bh);
}
-#endif
-
void udf_update_tag(char *data, int length)
{
tag *tptr = (tag *)data;
@@ -386,11 +347,11 @@
for (i=0; i<16; i++)
if (i != 4)
- tptr->tagChecksum += (Uint8)(data[i]);
+ tptr->tagChecksum += (uint8_t)(data[i]);
}
-void udf_new_tag(char *data, Uint16 ident, Uint16 version, Uint16 snum,
- Uint32 loc, int length)
+void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
+ uint32_t loc, int length)
{
tag *tptr = (tag *)data;
tptr->tagIdent = le16_to_cpu(ident);
@@ -399,114 +360,3 @@
tptr->tagLocation = le32_to_cpu(loc);
udf_update_tag(data, length);
}
-
-#ifndef __KERNEL__
-/*
- * udf_read_tagged_data
- *
- * PURPOSE
- * Read the first block of a tagged descriptor.
- * Usable from user-land.
- *
- * HISTORY
- * 10/4/98 dgb: written
- */
-int
-udf_read_tagged_data(char *buffer, int size, int fd, int block, int offset)
-{
- tag *tag_p;
- register Uint8 checksum;
- register int i;
- unsigned long offs;
-
- if (!buffer)
- {
- udf_errno = 1;
- return -1;
- }
-
- if ( !udf_blocksize )
- {
- udf_errno = 2;
- return -1;
- }
-
- if ( size < udf_blocksize )
- {
- udf_errno = 3;
- return -1;
- }
- udf_errno = 0;
-
- offs = (long)block * udf_blocksize;
- if ( lseek(fd, offs, SEEK_SET) != offs )
- {
- udf_errno = 4;
- return -1;
- }
-
- i = read(fd, buffer, udf_blocksize);
- if ( i < udf_blocksize )
- {
- udf_errno = 5;
- return -1;
- }
-
- tag_p = (tag *)(buffer);
-
- /* Verify the tag location */
- if ((block-offset) != tag_p->tagLocation)
- {
-#ifdef __KERNEL__
- printk(KERN_ERR "udf: location mismatch block %d, tag %d\n",
- block, tag_p->tagLocation);
-#else
- udf_errno = 6;
-#endif
- goto error_out;
- }
-
- /* Verify the tag checksum */
- checksum = 0U;
- for (i = 0; i < 4; i++)
- checksum += (Uint8)(buffer[i]);
- for (i = 5; i < 16; i++)
- checksum += (Uint8)(buffer[i]);
- if (checksum != tag_p->tagChecksum)
- {
-#ifdef __KERNEL__
- printk(KERN_ERR "udf: tag checksum failed\n");
-#else
- udf_errno = 7;
-#endif
- goto error_out;
- }
-
- /* Verify the tag version */
- if (tag_p->descVersion != 0x0002U)
- {
-#ifdef __KERNEL__
- printk(KERN_ERR "udf: tag version 0x%04x != 0x0002U\n",
- tag_p->descVersion);
-#else
- udf_errno = 8;
-#endif
- goto error_out;
- }
-
- /* Verify the descriptor CRC */
- if (tag_p->descCRC == udf_crc(buffer + 16, tag_p->descCRCLength, 0))
- {
- udf_errno = 0;
- return 0;
- }
-#ifdef __KERNEL__
- printk(KERN_ERR "udf: crc failure in udf_read_tagged\n");
-#else
- udf_errno = 9;
-#endif
-
-error_out:
- return -1;
-}
-#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)