From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45828 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727409AbeGaLvc (ORCPT ); Tue, 31 Jul 2018 07:51:32 -0400 From: David Howells In-Reply-To: <20180731094021.GC9836@amd> References: <20180731094021.GC9836@amd> <25489.1532953411@warthog.procyon.org.uk> <20180730143104.GB24051@amd> <20180730180842.GA5544@bombadil.infradead.org> <20180730183847.GB5544@bombadil.infradead.org> <20180730194938.GA12962@bombadil.infradead.org> <20180730210209.GY21725@thunk.org> <20180730235849.GA19692@bombadil.infradead.org> <20180731005802.GB21725@thunk.org> To: Pavel Machek Cc: dhowells@redhat.com, "Theodore Y. Ts'o" , Matthew Wilcox , Linus Torvalds , Al Viro , linux-fsdevel , Linux Kernel Mailing List Subject: Re: [PATCH 36/38] vfs: Add a sample program for the new mount API [ver #10] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18973.1533031913.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Tue, 31 Jul 2018 11:11:53 +0100 Message-ID: <18974.1533031913@warthog.procyon.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Pavel Machek wrote: > Proposal is "message %s foo %s\0param 1\0param2\0", only strings > allowed. I think that's too strict and you will need to allow integer values, IP addresses and possibly other things also. It could certainly have a limited set (e.g. no kernel pointers). You also haven't proposed what you think the internal interface should look like. > That's simple enough, yet allows translations. Yes and no. From the point of view of translating it, yes, it's easier, but from the point of view of actually writing these things in the kernel, it's not. So, currently, I have, say: cg_invalf(fc, "option or name mismatch, new: 0x%x \"%s\", old: 0x%x \"%s\"", ...); Now I can split that to separate out the option change error from the option change error: cg_invalf(fc, "Name mismatch, new: \"%s\", old: \"%s\"", ...); cg_invalf(fc, "Option mismatch, new: 0x%x, old: 0x%x", ...); but we still need to communicate to the logging function how many arguments we're actually passing. Now, I wouldn't consider this a fast-path, so actually counting the arguments encoded in the format string is probably fine - otherwise we have to actually pass the number of arguments in, e.g.: cg_invalf(fc, "Option mismatch, new: 0x%x, old: 0x%x", 2, ...); and then the kernel has to render the whole lot into Another example, in ext4 we have: printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d", so we could do something like: infof(fc, "EXT4-fs (%s): last error at time %u: %.*s:%d", ...); on mount. But the use of "%.*s" is a pain for your interface. We can't pass qualifiers like "*" to userspace, so either the caller would have to copy the string first or the logging routines would have to edit the format string. Though I suppose we could leave the editing to userspace. David