udf.h, libudf.sym, udf_private.h: expose struct udf_dirent_s and udf_get_lba()

udf_file.c: udf_read_block() Raise level of severity on warning when requested
blocks exceed the number in the extent.
This commit is contained in:
R. Bernstein
2010-10-22 23:39:19 -04:00
parent f4462b558d
commit 122aecc0a9
4 changed files with 58 additions and 56 deletions

View File

@@ -1,7 +1,5 @@
/* /*
$Id: udf.h,v 1.22 2008/03/25 15:59:09 karl Exp $ Copyright (C) 2005, 2006, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -37,7 +35,25 @@ typedef uint16_t partition_num_t;
/** Opaque structures. */ /** Opaque structures. */
typedef struct udf_s udf_t; typedef struct udf_s udf_t;
typedef struct udf_file_s udf_file_t; typedef struct udf_file_s udf_file_t;
typedef struct udf_dirent_s udf_dirent_t;
typedef struct udf_dirent_s {
char *psz_name;
bool b_dir; /* true if this entry is a directory. */
bool b_parent; /* True if has parent directory (e.g. not root
directory). If not set b_dir will probably
be true. */
udf_t *p_udf;
uint32_t i_part_start;
uint32_t i_loc, i_loc_end;
uint64_t dir_left;
uint8_t *sector;
udf_fileid_desc_t *fid;
/* This field has to come last because it is variable in length. */
udf_file_entry_t fe;
} udf_dirent_t;;
/** /**
Imagine the below a \#define'd value rather than distinct values of Imagine the below a \#define'd value rather than distinct values of
@@ -161,6 +177,9 @@ extern "C" {
char *udf_mode_string (mode_t i_mode, char *psz_str); char *udf_mode_string (mode_t i_mode, char *psz_str);
bool udf_get_lba(const udf_file_entry_t *p_udf_fe,
/*out*/ uint32_t *start, /*out*/ uint32_t *end);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@@ -21,6 +21,7 @@ udf_get_link_count
udf_get_part_number udf_get_part_number
udf_get_posix_filemode udf_get_posix_filemode
udf_opendir udf_opendir
udf_read_block
udf_readdir udf_readdir
udf_is_dir udf_is_dir
udf_open udf_open

View File

@@ -1,7 +1,5 @@
/* /*
$Id: udf_file.c,v 1.14 2008/04/18 16:02:10 karl Exp $ Copyright (C) 2005, 2006, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -220,6 +218,9 @@ offset_to_lba(const udf_dirent_t *p_udf_dirent, off_t i_offset,
If count is zero, read() returns zero and has no other results. If If count is zero, read() returns zero and has no other results. If
count is greater than SSIZE_MAX, the result is unspecified. count is greater than SSIZE_MAX, the result is unspecified.
It is the caller's responsibility to ensure that count is less
than the number of blocks recorded via p_udf_dirent.
If there is an error, cast the result to driver_return_code_t for If there is an error, cast the result to driver_return_code_t for
the specific error code. the specific error code.
*/ */
@@ -236,7 +237,9 @@ udf_read_block(const udf_dirent_t *p_udf_dirent, void * buf, size_t count)
if (i_lba != CDIO_INVALID_LBA) { if (i_lba != CDIO_INVALID_LBA) {
uint32_t i_max_blocks = CEILING(i_max_size, UDF_BLOCKSIZE); uint32_t i_max_blocks = CEILING(i_max_size, UDF_BLOCKSIZE);
if ( i_max_blocks < count ) { if ( i_max_blocks < count ) {
printf("Warning: don't know how to handle yet\n" ); fprintf(stderr, "Warning: read count %u is larger than %u size of entry\n",
count, i_max_blocks);
fprintf(stderr, "Warning: read count truncated to %u\n", count);
count = i_max_blocks; count = i_max_blocks;
} }
ret = udf_read_sectors(p_udf, buf, i_lba, count); ret = udf_read_sectors(p_udf, buf, i_lba, count);

View File

@@ -45,27 +45,6 @@ struct udf_s {
uint32_t fsd_offset; /* lba of fileset descriptor */ uint32_t fsd_offset; /* lba of fileset descriptor */
}; };
struct udf_dirent_s
{
char *psz_name;
bool b_dir; /* true if this entry is a directory. */
bool b_parent; /* True if has parent directory (e.g. not root
directory). If not set b_dir will probably
be true. */
udf_t *p_udf;
uint32_t i_part_start;
uint32_t i_loc, i_loc_end;
uint64_t dir_left;
uint8_t *sector;
udf_fileid_desc_t *fid;
/* This field has to come last because it is variable in length. */
udf_file_entry_t fe;
};
bool udf_get_lba(const udf_file_entry_t *p_udf_fe,
/*out*/ uint32_t *start, /*out*/ uint32_t *end);
#endif /* __CDIO_UDF_PRIVATE_H__ */ #endif /* __CDIO_UDF_PRIVATE_H__ */