Index | Thread | Search

From:
Walter Alejandro Iglesias <wai@roquesor.com>
Subject:
[wai@roquesor.com: Re: Message when moving file to ext2]
To:
tech@openbsd.org
Date:
Thu, 23 Oct 2025 13:04:07 +0200

Download raw body.

Thread
  • Walter Alejandro Iglesias:

    [wai@roquesor.com: Re: Message when moving file to ext2]

----- Forwarded message from Walter Alejandro Iglesias <wai@roquesor.com> -----

From: Walter Alejandro Iglesias <wai@roquesor.com>
Date: Thu, 23 Oct 2025 12:21:14 +0200
To: Martijn van Duren <openbsd+tech@list.imperialat.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Message-ID: <aPoBlzHxVLSeI3a_@chancha.roquesor.com>
In-Reply-To: <177461c7e1078fbd0f1a40bff4cfb5b06ff99fd6.camel@list.imperialat.at>
References: <aPkyHyzOhAoB45Pq@chancha.roquesor.com> <2af6026a9339aedc76305332ff4c26973723561a.camel@list.imperialat.at> <aPnjvHVSk-W3-RC7@chancha.roquesor.com> <177461c7e1078fbd0f1a40bff4cfb5b06ff99fd6.camel@list.imperialat.at>
Subject: Re: Message when moving file to ext2

On Thu, Oct 23, 2025 at 10:18:34AM +0200, Martijn van Duren wrote:
> On Thu, 2025-10-23 at 10:13 +0200, Walter Alejandro Iglesias wrote:
> > Hi Martijn,
> > 
> > On Thu, Oct 23, 2025 at 02:14:41AM +0200, Martijn van Duren wrote:
> > > On Wed, 2025-10-22 at 21:35 +0200, Walter Alejandro Iglesias wrote:
> > > > Hello list,
> > > > 
> > > > Is the message below expected when moving a file to an ext2 file system?
> > > > 
> > > >   $ doas mount -t ext2fs /dev/sd1i /mnt
> > > >   $ mv file /mnt
> > > >   mv: /mnt/file: set flags: Operation not permitted
> > > > 
> > > Moving to tech@
> > > 
> > > I ran into this issue some time ago with install(1). Back then I fixed
> > > it by making sure that install(1) doesn't call chflags(2) when the flags
> > > are identical.
> > > 
> > > The culprit for this warning is the following diff[0], which now always
> > > returns EPERM when a user tries to change flags (which we clearly aren't
> > > trying to do). Since I can't tell which other tools might bite us I
> > > think it might be wise to implement the logic I put into install(1) into
> > > the ext2fs driver.
> > > 
> > > The diff below works on my machine(tm). Could you give it a spin?
> > 
> > I applied your diff, compiled and installed the kernel, reboot (did I do
> > it right, or am I missing a step?), but the message is still appearing.
> > 
> That should work...
> 1) Could you try my updated diff from earlier this morning?
> 2) Could you give me all the information of the source and destination?
>    (filesystem, flags (ls -lo), anything else that you think might be
>     relevant)
> 3) And to rule out the obvious mistakes (I've been there too many times)
>    did you verify you booted the correct kernel (dmesg)

First of all.  Now I tried you second diff.  It works.

I know why my other attempt failed.  I didn't pay attention to the error
messages when I applied your first diff.  Your mail client (evolution)
adds quoted-printable garbage to the diff.  I had to correct both diff
manually.

Some info in case it's useful.  The source is my primary disk (any file
in my /home directory):

  $ dmesg | grep sd0
  sd0 at scsibus1 targ 1 lun 0: <NVMe, INTEL SSDPEKNU51, 002C>
  [...]

As destination I tried two different disks, both formated to ext2 that I
use to make backups.  One is a internal hard disk:

  $ dmesg | grep sd1
  sd1 at scsibus2 targ 4 lun 0: <ATA, WDC WD10EZEX-08M, 01.0> naa.50014ee25faacc3
  [...]

The other is a external solid state connected to a USB port:

  $ dmesg | grep sd2
  sd2 at scsibus5 targ 1 lun 0: <SanDisk, Portable SSD, 6004> serial.078155bb343030393934
  [...]





> > 
> > > 
> > > martijn@
> > > 
> > > ps. ext2 has a few more flags than our tools support[1]. But we could
> > > add nodump to the mapping, if only for a bit more complete insight.
> > > pps. Maybe it's a good idea to return EINVAL for UF_IMMUTABLE,
> > > UF_APPEND, and SF_ARCHIVED. That way it will be clear for the
> > > admin that certain flags aren't supported and won't be dropped
> > > silently. 
> > > 
> > > [0] https://marc.info/?l=openbsd-tech&m=174499208717194&w=2
> > > [1] https://wiki.osdev.org/Ext2#Inode_Flags
> > > 
> > > diff /usr/src
> > > path + /usr/src
> > > commit - 243c12c31b603d599722a28305b1c1bab6ea9d19
> > > blob - c0ffdeb9166c32d67d308129cd4c7c5b535cc620
> > > file + sys/ufs/ext2fs/ext2fs_vnops.c
> > > --- sys/ufs/ext2fs/ext2fs_vnops.c
> > > +++ sys/ufs/ext2fs/ext2fs_vnops.c
> > > @@ -210,6 +210,7 @@ ext2fs_setattr(void *v)
> > >  	struct vnode *vp = ap->a_vp;
> > >  	struct inode *ip = VTOI(vp);
> > >  	struct ucred *cred = ap->a_cred;
> > > +	u_long e2flags;
> > >  	int error;
> > >  
> > >  	/*
> > > @@ -227,16 +228,17 @@ ext2fs_setattr(void *v)
> > >  		if (cred->cr_uid != ip->i_e2fs_uid &&
> > >  			(error = suser_ucred(cred)))
> > >  			return (error);
> > > +		e2flags = (vap->va_flags & SF_APPEND) ? EXT2_APPEND : 0 |
> > > +		    (vap->va_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0;
> > >  		if (cred->cr_uid == 0) {
> > >  			if ((ip->i_e2fs_flags &
> > >  			    (EXT2_APPEND | EXT2_IMMUTABLE)) && securelevel > 0)
> > >  				return (EPERM);
> > >  			ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE);
> > > -			ip->i_e2fs_flags |=
> > > -			    (vap->va_flags & SF_APPEND) ? EXT2_APPEND : 0 |
> > > -			    (vap->va_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0;
> > > +			ip->i_e2fs_flags |= e2flags;
> > >  		} else {
> > > -			return (EPERM);
> > > +			if (e2flags != ip->i_e2fs_flags)
> > > +				return (EPERM);
> > >  		}
> > >  		ip->i_flag |= IN_CHANGE;
> > >  		if (vap->va_flags & (IMMUTABLE | APPEND))
> > > 
> 

-- 
Amar: cambiar de casa el alma.
		-- Constancio C. Vigil.

----- End forwarded message -----

-- 
Walter