Skip to content
Open
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
87 changes: 87 additions & 0 deletions doc/udftune.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
'\" t -*- coding: UTF-8 -*-
.\" Copyright (C) 2017-2021 Pali Rohár <[email protected]>
.\" Copyright (C) 2023 Johannes Truschnigg <[email protected]>
.\"
.\" 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
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH UDFTUNE 8 "udftools" "Commands"

.SH NAME
udftune \(em modify UDF filesystem characteristics

.SH SYNOPSIS
.BI "udftune [block\-options] [filesystem\-options] " device

.SH DESCRIPTION
\fBudftune\fP is a UDF-specific utility to modify various aspects of filesystem
metadata, in the spirit of \fBtune2fs\fP(8) and similar tools for other
filesystems. Its current implementation can mark an existing UDF device/image
read-only, or to reverse that and mark it read-write.

.SH OPTIONS

.SS "GENERAL OPTIONS"
.TP
.B \-h,\-\-help
Display the usage and the list of options.

.SS "BLOCK OPTIONS"
.TP
.BI \-b,\-\-blocksize= " block\-size "

.TP
.BI \-\-startblock= " start\-block "

.TP
.BI \-\-lastblock= " last\-block "

.TP
.BI \-\-vatblock= " vat\-block "

.TP
.B \-\-force

.TP
.B \-n,\-\-no\-write

For a comprehensive overview of the block-related options listed above, please
refer to \fBudflabel\fP(8).

.SS "FILESYSTEM OPTIONS"
.TP
.BI \-\-mark-ro
Mark the UDF filesystem on \fIdevice\fP ro (read-only) in its FSD and LVD.

.TP
.BI \-\-mark-rw
Mark the UDF filesystem on \fIdevice\fP rw (read+write) in its FSD and LVD.

.SH "EXIT STATUS"
\fBudftune\fP returns 0 if successful, non-zero if there are problems like
if the block device does not contain a UDF filesystem, or updating failed.

.SH AUTHOR
.nf
Johannes Truschnigg <[email protected]>
Pali Rohár <[email protected]>
.fi

.SH AVAILABILITY
\fBudftune\fP is part of the udftools package since after version 2.3 and is
available from https://github.com/pali/udftools/.

.SH "SEE ALSO"
\fBmkudffs\fP(8), \fBpktsetup\fP(8), \fBcdrwtool\fP(1), \fBudfinfo\fP(1),
\fBwrudf\fP(1)
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