From owner-freebsd-fs@freebsd.org Mon Nov 20 20:51:16 2017 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE4FDDF5149 for ; Mon, 20 Nov 2017 20:51:16 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A0A386C7B7 for ; Mon, 20 Nov 2017 20:51:16 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f181.google.com with SMTP id q101so17119279ioi.1 for ; Mon, 20 Nov 2017 12:51:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=7JAVkcMO7vWR5Xr7yVTsYXeQKagM25elts4aWwce1Fg=; b=dOTFsLrVGZAgDea9/knyHaJrxA8IpViwjdA0yfYwpzVfMSON01ppKdOmGRW66CEvjG bBlidUPixDWFVUdrcNs/rcFetYC02hLacpQNBLAtQjZEjizs64QDGk4HZKSwTmPqANFC O0lx5s4RtZp5d30sP7jv5OkEE4ViQXL7sXZQZIyDDH5paUJ8OUZ+KGuAHupMC6Y3tuBj ye0qMG/GwwN+xo+wiu6ux2Ui4AEloOXM3J0W7TwTKzehtdkHjAbdKSbx0BMY6vtU23NX OVdwpoop3hZ7sXrCYlWeEoR8bZkIFRi8C1wWStFbYIcw3pdVzFYVWmn4rjMd7QYDoVLu GaSg== X-Gm-Message-State: AJaThX5qGfPAejKwG1L+Ccu/MozkHjVCzOorBFgoQZaBeDbJHeBK7Bny VDiGetKgkrBJR57sQV2GyNeUfhu3 X-Google-Smtp-Source: AGs4zMZXij7uzLSYCWItqnMC0cWKGvyNctaaWy3PhbU4TPYJ5RVSU2NE2fkX73NNxTNzv0mO0pQlRg== X-Received: by 10.107.81.24 with SMTP id f24mr15045396iob.63.1511211070153; Mon, 20 Nov 2017 12:51:10 -0800 (PST) Received: from mail-io0-f173.google.com (mail-io0-f173.google.com. [209.85.223.173]) by smtp.gmail.com with ESMTPSA id 196sm4843682ioe.66.2017.11.20.12.51.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 12:51:10 -0800 (PST) Received: by mail-io0-f173.google.com with SMTP id i38so17142624iod.2 for ; Mon, 20 Nov 2017 12:51:10 -0800 (PST) X-Received: by 10.107.7.169 with SMTP id g41mr16016976ioi.38.1511211069886; Mon, 20 Nov 2017 12:51:09 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.165.150 with HTTP; Mon, 20 Nov 2017 12:51:09 -0800 (PST) In-Reply-To: References: From: Conrad Meyer Date: Mon, 20 Nov 2017 12:51:09 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: MSDOS Filesystem question related to "read-only" files To: Karl Denninger Cc: "freebsd-fs@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2017 20:51:17 -0000 On Mon, Nov 20, 2017 at 12:02 PM, Karl Denninger wrote: > root@Test-MCP:/mnt # ls -al > ... > -rwxr-xr-x 1 hdmcp wheel 127979 Nov 19 22:54 > cam2-2017-11-19-22-54-47.jpg > ... > root@Test-MCP:/mnt # chmod u-w * > root@Test-MCP:/mnt # ls -al > ... > -rwxr-xr-x 1 hdmcp wheel 127979 Nov 19 22:54 > cam2-2017-11-19-22-54-47.jpg > ... > Nope. The "w" is still there. > > No error returned from the "chmod" command (or if I call it from a C > program) but the file mode is NOT changed whether I'm doing it as the > superuser or as the owner of the file (and directory) Indeed, msdosfs does not reflect the READONLY attribute back to userspace in the form of the mode. That's a bug that could be fixed pretty easily: --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -287,6 +287,8 @@ msdosfs_getattr(struct vop_getattr_args *ap) vap->va_fileid = fileid; mode = S_IRWXU|S_IRWXG|S_IRWXO; + if ((dep->de_Attributes & ATTR_READONLY) != 0) + mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); vap->va_mode = mode & (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask); vap->va_uid = pmp->pm_uid; However, despite 'ls' showing 'w', it *does* set the READONLY attribute on the file. Try invoking ls(1) with '-o' and looking for the "rdonly" or "readonly" flag. Best, Conrad