From owner-freebsd-current Wed Oct 9 2:46:23 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 84B2237B401 for ; Wed, 9 Oct 2002 02:46:21 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEBD743EA3 for ; Wed, 9 Oct 2002 02:46:16 -0700 (PDT) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 1A58BAE160; Wed, 9 Oct 2002 02:46:16 -0700 (PDT) Date: Wed, 9 Oct 2002 02:46:16 -0700 From: Maxime Henrion To: "Vladimir B. Grebenschikov" Cc: freebsd-current@freebsd.org Subject: Re: DDB sysctl function Message-ID: <20021009094616.GP57622@elvis.mu.org> References: <1034097697.1548.2.camel@vbook.express.ru> <20021008182532.GM57622@elvis.mu.org> <1034110999.1146.3.camel@vbook.express.ru> <1034154560.900.6.camel@vbook.express.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1034154560.900.6.camel@vbook.express.ru> User-Agent: Mutt/1.4i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Vladimir B. Grebenschikov wrote: > ? Wed, 09.10.2002, ? 01:03, Vladimir B. Grebenschikov ???????: > > ? Tue, 08.10.2002, ? 22:25, Maxime Henrion ???????: > > > Vladimir B. Grebenschikov wrote: > > > > Hi > > > > > > > > Attached diff introduces new ddb interface - access to sysctl interface > > > [...] > > > > > > Looks like this would be very useful. I have a few comments, mainly > > > about style though. > > > > Attached fixed patch > > sorry, I have attached wong file > > > > > - There is a TOK_STRING_SIZE macro which defines the size of the the > > > db_tok_string variable. Use it instead of declaring several 1k > > > variables on the stack. > > > > It is not token buffers - it is buffers for sysctl data interchange, > > const 1024 changed to SYSCTL_DATA_BUFSIZE define. Yes, that's better, but you still do a strcpy() which assumes that SYSCTL_DATA_BUFSIZE >= TOK_STRING_SIZE, and there are still quite big variables on the stack, which can be a problem if someone invokes ddb while deep in the stack. What I meant in my previous mail is that you could malloc() these objects instead of putting them on the stack. Also, you don't need buffers that big since the size you need is bounded at max(sizeof(int), TOK_STRING_SIZE), which is likely to be TOK_STRING_SIZE :-). > > > - I'm not sure if using the context of the init process to do sysctl > > > calls is the right way to go. However, it is not very clear what you > > > should use to do this, at least to me. > > > > kernel_sysctl need thread pointer, it may be used in sysctl handlers. Yup, noone contested the fact that you need a thread pointer, the problem is that FIRST_THREAD_IN_PROC(initproc) is probably not the good one to use, and there probably isn't any good one to use at all. However, it might be acceptable to do it the way you do now. Cheers, Maxime To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message