From patchwork Thu Apr 8 10:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Pablo_Gonz=C3=A1lez?= X-Patchwork-Id: 1463727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=RCjY8vuK; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4FGGz14bg3z9sRf for ; Thu, 8 Apr 2021 20:02:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbhDHKCo (ORCPT ); Thu, 8 Apr 2021 06:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231134AbhDHKCn (ORCPT ); Thu, 8 Apr 2021 06:02:43 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7873DC061760 for ; Thu, 8 Apr 2021 03:02:32 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d124so1400761pfa.13 for ; Thu, 08 Apr 2021 03:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Dw/mCQpPHedRgnIBZEoWcG9ZuY/vsppZf9dMKka3+yo=; b=RCjY8vuKTWmf3KOzz0s5FmH0QVP5h75UE2YnqvVgojvQDaEdwVtAHnNrtRftJLE6xV QcU8ik8fTclIaFr6GVOnFf9WyOivw3S0abwNO2RwGkoVnvK0oAl0ClYSmF34/IvLF95R 1zjz9mLLhtuZQbnCd0uXLVGxNa5hd/jv7KBvFIOi7t3VsOka4zAMnsn83mBdKDAyRjnV bKMzRaRl4+VZh6k8Kex/TNLTZt5wgFpxBM0umffJhXxzst3G6WDm0DPsoHXb5E4GbhrS Xfty8D/YFS+exKRwkcCpmQ4WOvkO+FKQ2xAm/XjdB9ZRk2SRGDyGZZChM5nEU94FWis3 27Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Dw/mCQpPHedRgnIBZEoWcG9ZuY/vsppZf9dMKka3+yo=; b=tfZKd4jfIXkcEWptr4dStYiAo0uFDkHhSQZ26vER+hQ8tVoQRIu7VvZXRqZN7b0foR Aj7ojQ13uBI0u+dpjX9GmXMge/4paUsVDGW4vwM7VmbKi5jiKMOPp+ngPnyi6F+NsUOI /i9E0JoQaZ5WQcAWgH1c7gibv+ouyzFlOjeU//jbTaMUirCT5XcWSwWB9W+sequJuZQH 30+9sQtEh0MSummvnveolsLqzP2SuBzxiRSacB0CtvQRhvrXjImBc9MawV0cgZcR4UXg 5z9Pptpux2MIizhXxJA+bH3f6jV2EmK/XhpEx3vsLdtq7gwPbP/xDvKpD4bP6t+3JmdB xtnQ== X-Gm-Message-State: AOAM533RYa5W2sguXNCYs50cao+Z/C273OakDIsYPc/+0yHkp+MVzHDK QuvmAoXKZ7CDPvCZzcE43rQIKHnrhwcpc/Zt9vIx8MLa+pN0ew== X-Google-Smtp-Source: ABdhPJwuL+NjZnOZ39z90c/OHW23/RaGIhVxGGPZSMe0er1tomgs0E0fb5aPu+wKdM0n2MbuT/ItEe1fbjw/XdYOZ8U= X-Received: by 2002:a62:fb14:0:b029:22e:e189:c6b1 with SMTP id x20-20020a62fb140000b029022ee189c6b1mr6925139pfm.31.1617876152076; Thu, 08 Apr 2021 03:02:32 -0700 (PDT) MIME-Version: 1.0 From: =?utf-8?q?J=2E_Pablo_Gonz=C3=A1lez?= Date: Thu, 8 Apr 2021 12:02:20 +0200 Message-ID: Subject: [PATCH] smbinfo: Add command for displaying alternate data streams To: linux-cifs@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Hi, This patch adds a new command to smbinfo which retrieves and displays the list of alternate data streams for a file. Signed-off-by: Juan Pablo González Reviewed-by: Aurelien Aptel --- smbinfo | 41 +++++++++++++++++++++++++++++++++++++++++ smbinfo.rst | 2 ++ 2 files changed, 43 insertions(+) diff --git a/smbinfo b/smbinfo index 9752963..55c44e1 100755 --- a/smbinfo +++ b/smbinfo @@ -253,6 +253,10 @@ def main(): sap.add_argument("file") sap.set_defaults(func=cmd_filestandardinfo) + sap = subp.add_parser("filestreaminfo", help="Prints FileStreamInfo for a cifs file") + sap.add_argument("file") + sap.set_defaults(func=cmd_filestreaminfo) + sap = subp.add_parser("fsctl-getobjid", help="Prints the objectid of the file and GUID of the underlying volume.") sap.add_argument("file") sap.set_defaults(func=cmd_fsctl_getobjid) @@ -753,7 +757,44 @@ def cmd_secdesc(args): print(ace) off_dacl += ace.size +def cmd_filestreaminfo(args): + qi = QueryInfoStruct(info_type=0x1, file_info_class=22, input_buffer_length=INPUT_BUFFER_LENGTH) + try: + fd = os.open(args.file, os.O_RDONLY) + info = os.fstat(fd) + buf = qi.ioctl(fd) + except Exception as e: + print("syscall failed: %s"%e) + return False + print_filestreaminfo(buf) + +def print_filestreaminfo(buf): + offset = 0 + + while offset < len(buf): + + next_offset = struct.unpack_from(' 0): + stream_size = struct.unpack_from(' 0): + print() + if (stream_name=="::$DATA"): + print("Name: %s"% stream_name) + else: + print("Name: %s"% stream_name[stream_name.find(":") + 1 : stream_name.rfind(':$DATA')]) + print("Size: %d bytes"% stream_size) + print("Allocation size: %d bytes "% stream_alloc_size) + + if (next_offset == 0): + break + + offset+=next_offset + class KeyDebugInfoStruct: def __init__(self): self.suid = bytearray() diff --git a/smbinfo.rst b/smbinfo.rst index 7413849..1acf3c4 100644 --- a/smbinfo.rst +++ b/smbinfo.rst @@ -65,6 +65,8 @@ COMMAND `filestandardinfo`: Prints the FileStandardInformation class +`filestreaminfo`: Prints the FileStreamInformation class + `fsctl-getobjid`: Prints the ObjectID `getcompression`: Prints the compression setting for the file.