From patchwork Sun Nov 4 14:18:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1694311 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 4F44C3FD2B for ; Sun, 4 Nov 2012 14:18:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754293Ab2KDOSb (ORCPT ); Sun, 4 Nov 2012 09:18:31 -0500 Received: from mail-gh0-f174.google.com ([209.85.160.174]:51868 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779Ab2KDOSa (ORCPT ); Sun, 4 Nov 2012 09:18:30 -0500 Received: by mail-gh0-f174.google.com with SMTP id g15so874589ghb.19 for ; Sun, 04 Nov 2012 06:18:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=B2IfyV7BxrSurc/sNfjF3X8FfVEs1Nayo2nvyX0+c9M=; b=XmDCKWPSvdPOQ2mU5dJEi5MhGQCluUG+rGtaqMNE3YmPN2eWNkk65olMig4LYZBg2f lQ0SOU6n4lLbopMP6JkO45irLCB1DuSdmVWXfwserqW8xkn2GvAZfxzWbjcVuNKOyJav f5JeC2cH8a9KegEaurwbvwV6dgPpUbOV6GsYHm+TsIc//7jFZUWcv/vqjJk1nihkslws v+eA7yp25g1HBAe+wyp9euQg1ucrYrQzJxaj+nFp/GCn1i00t3qdzUCH4K7EHhReg5Mv QrQlTQC+NL89jnL6IUBk+qQSdTqqw7MVw6DPnc9cRA/1YpgwJLt8SZorwvv99JrQdR83 N8YQ== Received: by 10.236.143.131 with SMTP id l3mr6421887yhj.108.1352038706939; Sun, 04 Nov 2012 06:18:26 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id g6sm13603179ani.5.2012.11.04.06.18.24 (version=SSLv3 cipher=OTHER); Sun, 04 Nov 2012 06:18:25 -0800 (PST) From: Jeff Layton To: linux-cifs@vger.kernel.org Cc: shirishpargaonkar@gmail.com Subject: [PATCH 18/17] setcifsacl: consolidate SID copying routines Date: Sun, 4 Nov 2012 09:18:19 -0500 Message-Id: <1352038699-8935-1-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351947034-18876-1-git-send-email-jlayton@samba.org> References: <1351947034-18876-1-git-send-email-jlayton@samba.org> X-Gm-Message-State: ALoCoQmKi8lQHnpjgSDSlwFSyg907ZeT98x6OdDXNRx8KbHSgokDU44PMywSdFnuB5J1DUNs1L4r Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org ...instead of open-coding it thrice. Signed-off-by: Jeff Layton --- setcifsacl.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/setcifsacl.c b/setcifsacl.c index 04fa321..5016264 100644 --- a/setcifsacl.c +++ b/setcifsacl.c @@ -50,11 +50,22 @@ enum setcifsacl_actions { }; static void -copy_sec_desc(const struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, - int numaces, int acessize) +copy_cifs_sid(struct cifs_sid *dst, const struct cifs_sid *src) { int i; + dst->revision = src->revision; + dst->num_subauth = src->num_subauth; + for (i = 0; i < NUM_AUTHS; i++) + dst->authority[i] = src->authority[i]; + for (i = 0; i < src->num_subauth; i++) + dst->sub_auth[i] = src->sub_auth[i]; +} + +static void +copy_sec_desc(const struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, + int numaces, int acessize) +{ int osidsoffset, gsidsoffset, dacloffset; struct cifs_sid *owner_sid_ptr, *group_sid_ptr; struct cifs_sid *nowner_sid_ptr, *ngroup_sid_ptr; @@ -81,24 +92,12 @@ copy_sec_desc(const struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, /* copy owner sid */ owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + osidsoffset); nowner_sid_ptr = (struct cifs_sid *)((char *)pnntsd + osidsoffset); - - nowner_sid_ptr->revision = owner_sid_ptr->revision; - nowner_sid_ptr->num_subauth = owner_sid_ptr->num_subauth; - for (i = 0; i < NUM_AUTHS; i++) - nowner_sid_ptr->authority[i] = owner_sid_ptr->authority[i]; - for (i = 0; i < owner_sid_ptr->num_subauth; i++) - nowner_sid_ptr->sub_auth[i] = owner_sid_ptr->sub_auth[i]; + copy_cifs_sid(nowner_sid_ptr, owner_sid_ptr); /* copy group sid */ group_sid_ptr = (struct cifs_sid *)((char *)pntsd + gsidsoffset); ngroup_sid_ptr = (struct cifs_sid *)((char *)pnntsd + gsidsoffset); - - ngroup_sid_ptr->revision = group_sid_ptr->revision; - ngroup_sid_ptr->num_subauth = group_sid_ptr->num_subauth; - for (i = 0; i < NUM_AUTHS; i++) - ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; - for (i = 0; i < group_sid_ptr->num_subauth; i++) - ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i]; + copy_cifs_sid(ngroup_sid_ptr, group_sid_ptr); return; } @@ -106,18 +105,11 @@ copy_sec_desc(const struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, static int copy_ace(struct cifs_ace *dace, struct cifs_ace *sace) { - int i; - dace->type = sace->type; dace->flags = sace->flags; dace->access_req = sace->access_req; - dace->sid.revision = sace->sid.revision; - dace->sid.num_subauth = sace->sid.num_subauth; - for (i = 0; i < NUM_AUTHS; i++) - dace->sid.authority[i] = sace->sid.authority[i]; - for (i = 0; i < sace->sid.num_subauth; i++) - dace->sid.sub_auth[i] = sace->sid.sub_auth[i]; + copy_cifs_sid(&dace->sid, &sace->sid); dace->size = sace->size;