From patchwork Thu Apr 30 10:53:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 6301531 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C21EA9F32B for ; Thu, 30 Apr 2015 10:53:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9D06201CD for ; Thu, 30 Apr 2015 10:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B101620154 for ; Thu, 30 Apr 2015 10:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750878AbbD3KxI (ORCPT ); Thu, 30 Apr 2015 06:53:08 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:34781 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbbD3KxH (ORCPT ); Thu, 30 Apr 2015 06:53:07 -0400 Received: by wgso17 with SMTP id o17so57827524wgs.1 for ; Thu, 30 Apr 2015 03:53:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BZ04x3/cNPRm2vRdthiOA4pqLJvehn0Tzloyx0GQB98=; b=iy8vXWAOq9ccw5nDJ8xV3QnYX5PiwZPnoMYXqgN4YCWHVCiC8rdGOBOvCeXEfljrwF ZoQNHLGgzRTPXgas2gu7XJOno0WgTu8Os17pOTOwABXloueC7zlMqWoKMToG5qAndbdb BrrbCHGf8M/8jj19RHYwu17W1EWBV4u0hmkV5V+3Ysr/4EcW2XVkDUttdnA5bxNJNHG5 0Yy6PlfsBj9j8MK4zQAhhUmhCGphXjWvFGcBVbrF6VzFqLfCyntps9Mc8haXiqENBFrg BgA4lk0jewb2a5SGURgVm5Ciod1t5YxJXJeP8iNS4/HpRj7NUurmXhRyZTYeeA4u20Vv MlNA== X-Gm-Message-State: ALoCoQkLmhqGB1lz/wSY3qOr8PU6YPvZPY2QaPW7FXa739D047oIgWVVz6L7aAdgrhw8SlPGzNsS X-Received: by 10.180.88.72 with SMTP id be8mr4503090wib.42.1430391185801; Thu, 30 Apr 2015 03:53:05 -0700 (PDT) Received: from bgdev-debian.home (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by mx.google.com with ESMTPSA id vz8sm2740764wjc.27.2015.04.30.03.53.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Apr 2015 03:53:05 -0700 (PDT) From: Bartosz Golaszewski To: LKML Cc: linux-kbuild , Bartosz Golaszewski Subject: [RFC] scripts: kerrno.sh - errno translator Date: Thu, 30 Apr 2015 12:53:35 +0200 Message-Id: <1430391215-13768-1-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Shell script allowing to find errno definitions and descriptions in the kernel source. Signed-off-by: Bartosz Golaszewski --- This is a simple script I use when seeing messages like: some_func() failed: -123 to find out the actual errno meaning. The usage is very simple - just call 'scripts/kerrno.sh 1 4 -50 (...)'. I'm sending this as RFC in order to find out if there's any interest in merging this script with the kernel code. scripts/kerrno.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 scripts/kerrno.sh diff --git a/scripts/kerrno.sh b/scripts/kerrno.sh new file mode 100755 index 0000000..ebdc8da --- /dev/null +++ b/scripts/kerrno.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Get preprocessor definitions and descriptions of errno numbers from the +# Linux kernel source. +# +# This script parses all the C headers containing errno definitions in the +# Linux source tree and extracts their definitions and corresponding +# descriptions in order to quickly give users an idea on what kind of +# an error they're dealing with. +# +# Example: +# scripts/kerrno.sh 43 -12 3 +# +# Should be called from the top of the source tree. +# +# Copyright (C) 2015 Bartosz Golaszewski + +FILEPTRN=".*errno.*\.[ch]$" +ERRNOPTRN="\#define[\ \t]+E[A-Z0-9]+[\ \t]+[0-9]+[\ \t]+" + +usage() +{ + echo "$0: get info for error numbers" + echo + echo "Usage:" + echo "\t$0 " + echo + echo "\tExample: $0 -18 34 128" + echo +} + +if [ "$#" -eq "0" ] || ([ "$#" -eq "1" ] && [ "$1" = "--help" ]) +then + usage + exit +fi + +for WANTED in $@ +do + case ${WANTED#-} in + ''|*[!0-9]*) + echo "$WANTED: not a number"; + continue; + ;; + esac + + test "$WANTED" -lt "0" && WANTED=$(echo -n $WANTED | cut -d'-' -f2) + + echo "Errno $WANTED:" + find ./ -regex "$FILEPTRN" -exec grep -nPH "$ERRNOPTRN" {} \; \ + | tr -s ':' ' ' \ + | tr -s '\t' ' ' \ + | cut -d' ' -f1,2,4,5 | while read FILE LINE ERRNO NUM + do + if [ "$NUM" -eq "$WANTED" ] + then + echo -n "\t$ERRNO (" + echo -n "$(head $FILE -n $LINE | tail -1 | cut -d'*' -f2)" + echo ") defined in $FILE:$LINE" + fi + done +done