From nobody Thu Nov 6 18:51:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488238182992583.5285459739994; Mon, 27 Feb 2017 15:29:42 -0800 (PST) Received: from localhost ([::1]:57572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciUjc-0008LG-W7 for importer@patchew.org; Mon, 27 Feb 2017 18:29:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciUHy-0000mW-1W for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:01:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciUHu-0004C1-Uq for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:01:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34325 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciUHu-0004BK-Ex for qemu-devel@nongnu.org; Mon, 27 Feb 2017 18:01:02 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1RMrcNM080977 for ; Mon, 27 Feb 2017 18:01:01 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 28vm1want6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Feb 2017 18:01:01 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Feb 2017 23:00:59 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Feb 2017 23:00:57 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4CBC12190023; Mon, 27 Feb 2017 22:59:58 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1RN0vCv2163070; Mon, 27 Feb 2017 23:00:57 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67A22A4053; Mon, 27 Feb 2017 23:00:53 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DEA9A4055; Mon, 27 Feb 2017 23:00:53 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 27 Feb 2017 23:00:53 +0000 (GMT) Received: from bahia.lan (icon-9-164-183-34.megacenter.de.ibm.com [9.164.183.34]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 3B23A220225; Tue, 28 Feb 2017 00:00:56 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2017 00:00:21 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488236421-30983-1-git-send-email-groug@kaod.org> References: <1488236421-30983-1-git-send-email-groug@kaod.org> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022723-0040-0000-0000-00000350D558 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022723-0041-0000-0000-00001F0CD45F Message-Id: <1488236421-30983-32-git-send-email-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-27_17:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=13 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702270213 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 31/31] 9pfs: local: drop unused code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Aneesh Kumar K.V" , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that the all callbacks have been converted to use "at" syscalls, we can drop this code. Signed-off-by: Greg Kurz Reviewed-by: Stefan Hajnoczi --- hw/9pfs/9p-local.c | 198 -------------------------------------------------= ---- 1 file changed, 198 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 0b8bbf31a12d..f22a3c3654db 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -84,48 +84,6 @@ static void unlinkat_preserve_errno(int dirfd, const cha= r *path, int flags) =20 #define VIRTFS_META_DIR ".virtfs_metadata" =20 -static char *local_mapped_attr_path(FsContext *ctx, const char *path) -{ - int dirlen; - const char *name =3D strrchr(path, '/'); - if (name) { - dirlen =3D name - path; - ++name; - } else { - name =3D path; - dirlen =3D 0; - } - return g_strdup_printf("%s/%.*s/%s/%s", ctx->fs_root, - dirlen, path, VIRTFS_META_DIR, name); -} - -static FILE *local_fopen(const char *path, const char *mode) -{ - int fd, o_mode =3D 0; - FILE *fp; - int flags =3D O_NOFOLLOW; - /* - * only supports two modes - */ - if (mode[0] =3D=3D 'r') { - flags |=3D O_RDONLY; - } else if (mode[0] =3D=3D 'w') { - flags |=3D O_WRONLY | O_TRUNC | O_CREAT; - o_mode =3D S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWO= TH; - } else { - return NULL; - } - fd =3D open(path, flags, o_mode); - if (fd =3D=3D -1) { - return NULL; - } - fp =3D fdopen(fd, mode); - if (!fp) { - close(fd); - } - return fp; -} - static FILE *local_fopenat(int dirfd, const char *name, const char *mode) { int fd, o_mode =3D 0; @@ -238,135 +196,6 @@ out: return err; } =20 -static int local_create_mapped_attr_dir(FsContext *ctx, const char *path) -{ - int err; - char *attr_dir; - char *tmp_path =3D g_strdup(path); - - attr_dir =3D g_strdup_printf("%s/%s/%s", - ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR); - - err =3D mkdir(attr_dir, 0700); - if (err < 0 && errno =3D=3D EEXIST) { - err =3D 0; - } - g_free(attr_dir); - g_free(tmp_path); - return err; -} - -static int local_set_mapped_file_attr(FsContext *ctx, - const char *path, FsCred *credp) -{ - FILE *fp; - int ret =3D 0; - char buf[ATTR_MAX]; - char *attr_path; - int uid =3D -1, gid =3D -1, mode =3D -1, rdev =3D -1; - - attr_path =3D local_mapped_attr_path(ctx, path); - fp =3D local_fopen(attr_path, "r"); - if (!fp) { - goto create_map_file; - } - memset(buf, 0, ATTR_MAX); - while (fgets(buf, ATTR_MAX, fp)) { - if (!strncmp(buf, "virtfs.uid", 10)) { - uid =3D atoi(buf+11); - } else if (!strncmp(buf, "virtfs.gid", 10)) { - gid =3D atoi(buf+11); - } else if (!strncmp(buf, "virtfs.mode", 11)) { - mode =3D atoi(buf+12); - } else if (!strncmp(buf, "virtfs.rdev", 11)) { - rdev =3D atoi(buf+12); - } - memset(buf, 0, ATTR_MAX); - } - fclose(fp); - goto update_map_file; - -create_map_file: - ret =3D local_create_mapped_attr_dir(ctx, path); - if (ret < 0) { - goto err_out; - } - -update_map_file: - fp =3D local_fopen(attr_path, "w"); - if (!fp) { - ret =3D -1; - goto err_out; - } - - if (credp->fc_uid !=3D -1) { - uid =3D credp->fc_uid; - } - if (credp->fc_gid !=3D -1) { - gid =3D credp->fc_gid; - } - if (credp->fc_mode !=3D -1) { - mode =3D credp->fc_mode; - } - if (credp->fc_rdev !=3D -1) { - rdev =3D credp->fc_rdev; - } - - - if (uid !=3D -1) { - fprintf(fp, "virtfs.uid=3D%d\n", uid); - } - if (gid !=3D -1) { - fprintf(fp, "virtfs.gid=3D%d\n", gid); - } - if (mode !=3D -1) { - fprintf(fp, "virtfs.mode=3D%d\n", mode); - } - if (rdev !=3D -1) { - fprintf(fp, "virtfs.rdev=3D%d\n", rdev); - } - fclose(fp); - -err_out: - g_free(attr_path); - return ret; -} - -static int local_set_xattr(const char *path, FsCred *credp) -{ - int err; - - if (credp->fc_uid !=3D -1) { - uint32_t tmp_uid =3D cpu_to_le32(credp->fc_uid); - err =3D setxattr(path, "user.virtfs.uid", &tmp_uid, sizeof(uid_t),= 0); - if (err) { - return err; - } - } - if (credp->fc_gid !=3D -1) { - uint32_t tmp_gid =3D cpu_to_le32(credp->fc_gid); - err =3D setxattr(path, "user.virtfs.gid", &tmp_gid, sizeof(gid_t),= 0); - if (err) { - return err; - } - } - if (credp->fc_mode !=3D -1) { - uint32_t tmp_mode =3D cpu_to_le32(credp->fc_mode); - err =3D setxattr(path, "user.virtfs.mode", &tmp_mode, sizeof(mode_= t), 0); - if (err) { - return err; - } - } - if (credp->fc_rdev !=3D -1) { - uint64_t tmp_rdev =3D cpu_to_le64(credp->fc_rdev); - err =3D setxattr(path, "user.virtfs.rdev", &tmp_rdev, sizeof(dev_t= ), 0); - if (err) { - return err; - } - } - return 0; -} - static int local_set_mapped_file_attrat(int dirfd, const char *name, FsCred *credp) { @@ -516,33 +345,6 @@ static int local_set_xattrat(int dirfd, const char *pa= th, FsCred *credp) return 0; } =20 -static int local_post_create_passthrough(FsContext *fs_ctx, const char *pa= th, - FsCred *credp) -{ - char *buffer; - - buffer =3D rpath(fs_ctx, path); - if (lchown(buffer, credp->fc_uid, credp->fc_gid) < 0) { - /* - * If we fail to change ownership and if we are - * using security model none. Ignore the error - */ - if ((fs_ctx->export_flags & V9FS_SEC_MASK) !=3D V9FS_SM_NONE) { - goto err; - } - } - - if (chmod(buffer, credp->fc_mode & 07777) < 0) { - goto err; - } - - g_free(buffer); - return 0; -err: - g_free(buffer); - return -1; -} - static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd, const char *name, FsCred *credp) { --=20 2.7.4