From patchwork Wed Feb 13 05:47:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ronnie Sahlberg X-Patchwork-Id: 1040958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43zpTL2Vv3z9s7h for ; Wed, 13 Feb 2019 16:47:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729004AbfBMFru (ORCPT ); Wed, 13 Feb 2019 00:47:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbfBMFrt (ORCPT ); Wed, 13 Feb 2019 00:47:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BB756696E; Wed, 13 Feb 2019 05:47:49 +0000 (UTC) Received: from test1135.test.redhat.com (vpn2-54-96.bne.redhat.com [10.64.54.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF5335D9D1; Wed, 13 Feb 2019 05:47:48 +0000 (UTC) From: Ronnie Sahlberg To: linux-cifs Cc: Steve French Subject: [PATCH 2/2] smbinfo: add FileFsFullSizeInformation Date: Wed, 13 Feb 2019 15:47:37 +1000 Message-Id: <20190213054737.31425-3-lsahlber@redhat.com> In-Reply-To: <20190213054737.31425-1-lsahlber@redhat.com> References: <20190213054737.31425-1-lsahlber@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Feb 2019 05:47:49 +0000 (UTC) Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Signed-off-by: Ronnie Sahlberg --- smbinfo.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ smbinfo.rst | 2 ++ 2 files changed, 51 insertions(+) diff --git a/smbinfo.c b/smbinfo.c index c2cea9e..6375db7 100644 --- a/smbinfo.c +++ b/smbinfo.c @@ -67,6 +67,8 @@ usage(char *name) " Prints FileBasicInfo for a cifs file.\n" " fileeainfo:\n" " Prints FileEAInfo for a cifs file.\n" + " filefsfullsizeinfo:\n" + " Prints FileFsFullSizeInfo for a cifs share.\n" " fileinternalinfo:\n" " Prints FileInternalInfo for a cifs file.\n" " filemodeinfo:\n" @@ -492,6 +494,51 @@ fileeainfo(int f) free(qi); } +static void +print_filefullsizeinfo(uint8_t *sd) +{ + uint32_t u32; + uint64_t u64; + + memcpy(&u64, &sd[0], 8); + printf("Total Allocation Units: %" PRIu64 "\n", le64toh(u64)); + + memcpy(&u64, &sd[8], 8); + printf("Caller Available Allocation Units: %" PRIu64 "\n", + le64toh(u64)); + + memcpy(&u64, &sd[16], 8); + printf("Actual Available Allocation Units: %" PRIu64 "\n", + le64toh(u64)); + + memcpy(&u32, &sd[24], 4); + printf("Sectors Per Allocation Unit: %" PRIu32 "\n", le32toh(u32)); + + memcpy(&u32, &sd[28], 4); + printf("Bytes Per Sector: %" PRIu32 "\n", le32toh(u32)); +} + +static void +filefsfullsizeinfo(int f) +{ + struct smb_query_info *qi; + + qi = malloc(sizeof(struct smb_query_info) + 32); + memset(qi, 0, sizeof(qi) + 32); + qi->info_type = 0x02; + qi->file_info_class = 7; + qi->additional_information = 0; + qi->input_buffer_length = 32; + + if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) { + fprintf(stderr, "ioctl failed with %s\n", strerror(errno)); + exit(1); + } + + print_filefullsizeinfo((uint8_t *)(&qi[1])); + free(qi); +} + static void fileallinfo(int f) { @@ -759,6 +806,8 @@ int main(int argc, char *argv[]) filebasicinfo(f); else if (!strcmp(argv[1], "fileeainfo")) fileeainfo(f); + else if (!strcmp(argv[1], "filefsfullsizeinfo")) + filefsfullsizeinfo(f); else if (!strcmp(argv[1], "fileinternalinfo")) fileinternalinfo(f); else if (!strcmp(argv[1], "filemodeinfo")) diff --git a/smbinfo.rst b/smbinfo.rst index 2119f93..7bdbda4 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -49,6 +49,8 @@ COMMAND `fileeainfo`: Prints the FileEaInformation class +`filefsfullsizeinfo`: Prints the FileFsFullSizeInformation class + `fileinternalinfo`: Prints the FileInternalInformation class `filemodeinfo`: Prints the FileModeInformation class