Commit Graph

104 Commits

Author SHA1 Message Date
Benno Schulenberg aa06617f6e textual: remove square brackets from around three dots
Also improve some option descriptions here and there.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:12:13 +02:00
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak 145766440a losetup: tiny change to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Karel Zak 48f1f38b73 losetup: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Ondrej Oprala 7e86cd5470 losetup: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Karel Zak 5f68593d7a losetup: remove warning for unsupported -e and -E
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 09:08:40 +01:00
Karel Zak 961d69f799 losetup, mount: remove --pass-fd at all
The option is unsupported since v2.23, let's cleanup man pages and
code to remove it at all.

Reported-by: "Dale R. Worley" <worley@alum.mit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 09:02:36 +01:00
Sami Kerola f614b73c0e losetup, agetty: remove unnecessary if's before free()
Reference: http://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/useless-if-before-free
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-02 10:59:20 +01:00
Benno Schulenberg 9c47f25e8d losetup: cut the remaining little block of help text into slices too
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-09 11:40:08 +02:00
Karel Zak a7d5202b5e losetup: don't require 512-byte aligned offsets
Kernel aligns the device size, but the offset where the device starts
is not required to be aligned.

 # losetup --offset 32 -f file.img

is just fine, the final size of the look device will be (in sectors)

  (backing_file_size - offset) >> 9

so we have to do the same in userspace when we check for successful
set capacity ioctl.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-01 15:52:11 +02:00
Yuri Chornoivan 0d0d12adf8 Fix various typos 2013-09-28 13:33:59 +03:00
Karel Zak 5c32f352c8 losetup: use TT_FL_FREEDATA for tt table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +02:00
Karel Zak 3cb2413b02 losetup: use loop-control to explicitly ask for device
Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example

  losetup -f foo.img

Unfortunately, losetup(8) allows to ask for specified device

  losetup /dev/loop100 foo.img

and in this case we assume that the device already exists in the
system. This is incorrect, we should be able to use loop-control
LOOP_CTL_ADD ioctl to ask for the specified device.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 11:04:35 +02:00
Karel Zak 21ce3f3a4e losetup: fix loop device name usage
The code is not paranoid enough, loopcxt_set_device() only set the
device name to loopdev struct, but it does not check if the device
really exists.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-05 16:08:34 +02:00
Karel Zak 6d62bc0f9b losetup: make -j <path> more robust
It's usually unnecessary as we compare devno and ino, but let's
use absolute paths for situations when it's necessary to compare
paths as strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-05 15:35:26 +02:00
Karel Zak 01307ecf1b losetup: set errno for misaligned offsets
References: https://bugs.archlinux.org/task/36189
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-19 17:15:44 +02:00
Benno Schulenberg 97b820bffd textual: improve clarity of some error messages
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:29:44 +02:00
Benno Schulenberg 136b23efde textual: harmonize some loop-device error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:11:13 +02:00
Karel Zak 9f56106df6 losetup: add --raw and --noheadings
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 12:00:24 +02:00
Karel Zak b048b8af3a losetup: use warn_size() for regular files only
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 11:00:47 +02:00
Jeff Mahoney 293714c0d1 loopdev: sync capacity after setting it
I recently tried to mount an hfsplus file system from an image file with
a partition table by using the loop offset and sizelimit options to specify
the location of the file system.

hfsplus stores some metadata at a set offset from the end of the partition,
so it's sensitive to the device size reported by the kernel.

It worked with this:

But failed with this:

/dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000
/dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000

/proc/partitions shows the correct number of blocks to match the sizelimit.

But if I set a breakpoint in mount before the mount syscall, I could see:
102400000
102432768

The kernel loop driver will set the gendisk capacity of the device at
LOOP_SET_STATUS64 but won't sync it to the block device until one of two
conditions are met: All open file descriptors referring to the device are
closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl
is called to sync it. Since mount opens the device and passes it directly
to the mount syscall after LOOP_SET_STATUS64 without closing and reopening
it, the sizelimit argument is effectively ignroed. The capacity needs to
be synced immediately for it to work as expected.

This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since
the device isn't yet released to the user, so it's safe to sync the capacity
immediately.

[kzak@redhat.com: - port to the current git HEAD,
                  - use uint64_t]

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-09 14:32:50 +02:00
Sami Kerola 114ade3d1b losetup: allow -j option argument to be relative path
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:56:03 +02:00
Sami Kerola 59a4ed117c losetup: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:05 +01:00
Sami Kerola e0b0676988 losetup: fix declarations [smatch scan]
sys-utils/losetup.c:309:2: error: 'for' loop initial declarations are only allowed in C99 mode
sys-utils/losetup.c:374:2: error: 'for' loop initial declarations are only allowed in C99 mode

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:23 +01:00
Karel Zak 65178cb3f2 losetup: allow to use -O without --list
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 14:36:29 +01:00
Karel Zak 4ad996d7f9 losetup: rename SIZE->SIZELIMIT
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 13:24:45 +01:00
Ondrej Oprala 896352d390 losetup: add --list and --output option
The --list --all is the default output:

  # losetup
  NAME       SIZE OFFSET AUTOCLEAR RO BACK-FILE
  /dev/loop0    0      0         0  0 /home/fs-images/swap.img
  /dev/loop1    0    100         0  0 /home/fs-images/disk.img

[kzak@redhat.com: - default to --all if no device specified,
                  - cleanup column names (add BACK- prefix)
                  - add MAJ:MIN to of the loopdev device]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 13:08:00 +01:00
Karel Zak f4bf95926a lib/loopdev: improve debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-17 11:42:21 +02:00
Ludwig Nussel 5cf05c7147 mount: losetup: remove obsolete encryption support
kernel cryptoloop is deprecated since ages and support for cryptoloop
in util-linux is incomplete/broken.
- no password hashing
- last 8 bit of key are always set to zero
- no binary keys possible (stops reading key at \n and \0)

In the past some Distros added the above features with patches. So
remove cryptoloop support from util-linux completely to make sure
people won't try using it.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-11 10:46:11 +02:00
Benno Schulenberg e9e7698eb4 textual: add missing comma and colon in some help texts
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2012-09-04 17:27:50 +02:00
Karel Zak c1ac31445c losetup: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:25:59 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak defa0710b6 lib/loopdev: use warn_unused_result forimportant functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 10:40:43 +02:00
Sami Kerola 96801c4826 losetup: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Karel Zak 3554545636 losetup: warn about backing file size
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 14:34:16 +02:00
Karel Zak cda4f8f10b losetup: more verbose failed setup error mesage
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-28 11:36:59 +02:00
Karel Zak 20a3998222 sys-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:45:17 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Karel Zak e9e426eb78 losetup: use strtosize_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-30 16:18:30 +02:00
Daniel Drake ce65b29ac4 losetup: Fix setting of sizelimit on new loop devices
"losetup --offset 10 --sizelimit 20 foo.img" was producing
a loop device with offset 20 and no sizelimit. Looks like a typo,
fix it.

Signed-off-by: Daniel Drake <dsd@laptop.org>
2012-03-13 12:21:49 +01:00
Karel Zak a3b421dfac losetup: fix compiler warnings [-Wpointer-sign -Wformat]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 16:36:55 +01:00
Karel Zak 6c503d5916 losetup: move xgetpass() to lib/xgetpass.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 15:17:06 +01:00
Karel Zak 916bf85e62 losetup: add --partscan option
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09 23:28:50 +01:00
Karel Zak 934df30dd0 losetup: cleanup headers, cmdline checks
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:20:07 +01:00
Karel Zak aadb930377 losetup: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 6da69b83a6 losetup: check to control debug output
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 09ec0c0a97 losetup: print info about one device
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak c7e0925def losetup: rewrite loop setup
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak bcdbdc72cb losetup: rewrite -f
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak c654c4f0a3 losetup: rewrite -d and -D
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 6e90a44c1e losetup: rewrite -c
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak bc0ac075a9 losetup: rewrite -j
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 39fde1373d losetup: rewrite -a
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak bd6d0d039c losetup: move to sys-utils directory
Now losetup(8) is independent on mount/ stuff at all.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-20 13:07:54 +01:00