Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SUBDIRS = libudffs mkudffs cdrwtool pktsetup udffsck udfinfo udflabel wrudf doc
SUBDIRS = libudffs mkudffs cdrwtool pktsetup udffsck udfinfo udflabel udftune wrudf doc
dist_doc_DATA = AUTHORS COPYING NEWS README
EXTRA_DIST = autogen.sh Doxyfile
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ AC_SUBST(LTLIBOBJS)

AM_CONDITIONAL(USE_READLINE, test "$readline_found" = "yes")

AC_CONFIG_FILES(Makefile libudffs/Makefile mkudffs/Makefile cdrwtool/Makefile pktsetup/Makefile udffsck/Makefile udfinfo/Makefile udflabel/Makefile wrudf/Makefile doc/Makefile)
AC_CONFIG_FILES(Makefile libudffs/Makefile mkudffs/Makefile cdrwtool/Makefile pktsetup/Makefile udffsck/Makefile udfinfo/Makefile udflabel/Makefile udftune/Makefile wrudf/Makefile doc/Makefile)

AC_OUTPUT
46 changes: 0 additions & 46 deletions udfinfo/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,6 @@
#include "options.h"
#include "readdisc.h"

static uint64_t get_size(int fd)
{
struct stat st;
uint64_t size;
off_t offset;

if (fstat(fd, &st) == 0)
{
if (S_ISBLK(st.st_mode) && ioctl(fd, BLKGETSIZE64, &size) == 0)
return size;
else if (S_ISREG(st.st_mode))
return st.st_size;
}

offset = lseek(fd, 0, SEEK_END);
if (offset == (off_t)-1)
{
fprintf(stderr, "%s: Error: Cannot detect size of disk: %s\n", appname, strerror(errno));
exit(1);
}

if (lseek(fd, 0, SEEK_SET) != 0)
{
fprintf(stderr, "%s: Error: Cannot seek to start of disk: %s\n", appname, strerror(errno));
exit(1);
}

return offset;
}

static int get_sector_size(int fd)
{
int size;

if (ioctl(fd, BLKSSZGET, &size) != 0)
return 0;

if (size < 512 || size > 32768 || (size & (size - 1)))
{
fprintf(stderr, "%s: Warning: Disk logical sector size (%d) is not suitable for UDF\n", appname, size);
return 0;
}

return size;
}

static uint32_t compute_windows_serial_num(struct udf_disc *disc)
{
uint8_t *buffer = (uint8_t *)disc->udf_fsd;
Expand Down
46 changes: 46 additions & 0 deletions udfinfo/readdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2398,3 +2398,49 @@ int read_disc(int fd, struct udf_disc *disc)

return 0;
}

uint64_t get_size(int fd)
{
struct stat st;
uint64_t size;
off_t offset;

if (fstat(fd, &st) == 0)
{
if (S_ISBLK(st.st_mode) && ioctl(fd, BLKGETSIZE64, &size) == 0)
return size;
else if (S_ISREG(st.st_mode))
return st.st_size;
}

offset = lseek(fd, 0, SEEK_END);
if (offset == (off_t)-1)
{
fprintf(stderr, "%s: Error: Cannot detect size of disk: %s\n", appname, strerror(errno));
exit(1);
}

if (lseek(fd, 0, SEEK_SET) != 0)
{
fprintf(stderr, "%s: Error: Cannot seek to start of disk: %s\n", appname, strerror(errno));
exit(1);
}

return offset;
}

int get_sector_size(int fd)
{
int size;

if (ioctl(fd, BLKSSZGET, &size) != 0)
return 0;

if (size < 512 || size > 32768 || (size & (size - 1)))
{
fprintf(stderr, "%s: Warning: Disk logical sector size (%d) is not suitable for UDF\n", appname, size);
return 0;
}

return size;
}
4 changes: 4 additions & 0 deletions udfinfo/readdisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
#ifndef READDISC_H
#define READDISC_H

#include <linux/fs.h>

struct udf_disc;

uint64_t get_size(int);
int get_sector_size(int);
int read_disc(int, struct udf_disc *);

#endif /* READDISC_H */
2 changes: 1 addition & 1 deletion udflabel/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sbin_PROGRAMS = udflabel
udflabel_LDADD = $(top_builddir)/libudffs/libudffs.la
udflabel_SOURCES = main.c options.c ../udfinfo/readdisc.c options.h ../udfinfo/readdisc.h ../include/ecma_167.h ../include/osta_udf.h ../include/libudffs.h ../include/bswap.h
udflabel_SOURCES = main.c options.c ../udfinfo/readdisc.c ../udftune/updatedisc.c options.h ../udftune/updatedisc.h ../udfinfo/readdisc.h ../include/ecma_167.h ../include/osta_udf.h ../include/libudffs.h ../include/bswap.h
AM_CPPFLAGS = -I$(top_srcdir)/include
Loading