Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: add selinux labels to whiteout inodes
Date: Mon, 20 Jun 2022 18:06:48 -0500	[thread overview]
Message-ID: <9b86c15d-042e-26ed-095c-67910d90ddc6@redhat.com> (raw)
In-Reply-To: <1655765731-21078-1-git-send-email-sandeen@redhat.com>

I had mentioned this problem in passing to dchinner, and came away with
a vague sense that I might be Doing It Wrong. So I should have labeled
the patch RFC, I suppose.

An easy way to demonstrate the selinux label result is with this test
program, as provided by the bug reporter.  ls -lZ will then show you
the resulting labels on each file.

#define _GNU_SOURCE
#include <sys/mount.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
	int rc, fd, dirfd;
	rc = mkdir("upper", 0700);
	if ((rc != 0) && (errno != EEXIST)) {
		perror("mkdir");
		return rc;
	}
	rc = unlink("upper/0");
	if ((rc != 0) && (errno != ENOENT)) {
		perror("unlink");
		return rc;
	}
	rc = unlink("upper/empty");
	if ((rc != 0) && (errno != ENOENT)) {
		perror("unlink");
		return rc;
	}
	dirfd = open("upper", O_PATH);
	if (dirfd == -1) {
		perror("open");
		return dirfd;
	}
	fd = creat("upper/empty", 0600);
	if (fd == -1) {
		perror("creat");
		return fd;
	}
	close(fd);
	rc = renameat2(dirfd, "empty", dirfd, "0", RENAME_WHITEOUT);
	if (rc == -1) {
		perror("renameat2");
		return rc;
	}
	close(dirfd);
	return 0;
}


  reply	other threads:[~2022-06-20 23:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 22:55 [PATCH] xfs: add selinux labels to whiteout inodes Eric Sandeen
2022-06-20 23:06 ` Eric Sandeen [this message]
2022-06-20 23:41 ` Dave Chinner
2022-06-21  1:38 ` [PATCH V2] " Eric Sandeen
2022-06-22 23:30   ` Darrick J. Wong
2022-06-22 23:41     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b86c15d-042e-26ed-095c-67910d90ddc6@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox