Bug 503726 - cannot create snapshot (inappropriate ioctl); wrong directory opened
Summary: cannot create snapshot (inappropriate ioctl); wrong directory opened
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: btrfs-progs
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Josef Bacik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 572958 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-06-02 12:21 UTC by Tomasz Torcz
Modified: 2010-03-12 13:27 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-06-02 13:59:11 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
name is first argument ot -s, and path is second (520 bytes, patch)
2009-06-02 12:38 UTC, Tomasz Torcz
no flags Details | Diff

Description Tomasz Torcz 2009-06-02 12:21:25 UTC
Description of problem:
I cannot snapshot neither directory nor whole volume using btrfsprogs in F11.
I have LUKS-encrypted partition, over it I have single partition btrfs:

/dev/dm-5 on /media/WDP-Crypt type btrfs (rw,nosuid,nodev,uhelper=devkit)


Version-Release number of selected component (if applicable):
btrfs-progs-0.18-4.fc11.x86_64
kernel-2.6.29.4-167.fc11.x86_64


[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /media/WDP-Crypt/Backup/
ioctl:: Inappropriate ioctl for device
[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /media/WDP-Crypt/
ioctl:: Inappropriate ioctl for device
[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /dev/dm-5 
ioctl:: Inappropriate ioctl for device
  

After some stracing and debugging I found following two errors in btrfsctl.c:
1) snapshot name is treated as directory to be snapshotted
2) dirname() strips the parameter and leaves "." as dir to be snapshotted. This happens after following lines in btrfsctl.c:

 snap_location = strdup(fullpath);
 snap_location = dirname(snap_location);

(snap_location equals "." afterwards). Look into following strace snippet:

stat(".", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=20480, ...}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
stat("/media/WDP-Crypt/Backup/", {st_mode=S_IFDIR|0755, st_size=82, ...}) = 0
open("/media/WDP-Crypt/Backup/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
ioctl(3, 0x50009401, 0x7ffff3e192e0)    = -1 ENOTTY (Inappropriate ioctl for device)


first "." is opened as fd3, then correct dir as fd4, and lastly *fd3* is snapshotted.

Comment 1 Tomasz Torcz 2009-06-02 12:38:41 UTC
Created attachment 346244 [details]
name is first argument ot -s, and path is second

Comment 2 Josef Bacik 2009-06-02 13:59:11 UTC
Ok looks like the documentation is wrong.  The way this is supposed to work is you do

btrfsctl -s /mnt/btrfs/snapshot_name /mnt/btrfs

that should work.  Sorry for the confusion, I'm fixing the wiki so it makes more sense.

Comment 3 Mario Ceresa 2010-03-12 13:27:41 UTC
*** Bug 572958 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.