From owner-freebsd-hackers@freebsd.org Tue Oct 4 02:29:11 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C91EAF43E5 for ; Tue, 4 Oct 2016 02:29:11 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 82AE4695; Tue, 4 Oct 2016 02:29:11 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from julian-mbp3.pixel8networks.com (50-196-156-133-static.hfc.comcastbusiness.net [50.196.156.133]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id u942Stdv042621 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 3 Oct 2016 19:29:03 -0700 (PDT) (envelope-from julian@freebsd.org) Subject: Re: Proper way to add vendor-specific syscalls? [Correct answer] :-) To: freebsd-hackers@freebsd.org, Alan Somers References: From: Julian Elischer Message-ID: <7f0a642b-9c05-3bb6-53ee-66424a26b661@freebsd.org> Date: Mon, 3 Oct 2016 19:28:50 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2016 02:29:11 -0000 On 3/10/2016 10:48 AM, Alan Somers wrote: > What's the proper way to add a vendor-specific syscall? The comments > in kern/syscalls.master suggest that they should be put in the range > from 151-180, but most of that range is actually occupied. Only five > nosys slots are available. If I add syscalls to the end of the list, > they'll likely collide with future standard syscalls. Should I just > added ~100 nosys syscalls to the end of the list, and put my custom > syscalls afterwards? Is there any penalty to lengthening the list? > > -Alan > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" the correct way is to allow them to dynamically allocate a syscall, (assuming they are in a module) see man modstat(2) the syscall number is in the modspecfic data. also see the SYSCALL_MODULE(2) man page read /usr/share/examples/kld/syscall and read both the module and the test program. key parts are: (in the module: the module needs something like: static int ddfenabled_offset = NO_SYSCALL; static struct sysent ddfenabled_sysent = { AS(ddfenabled_args), (sy_call_t *)ddfenabled, AUE_NULL, NULL, 0, 0, 0 }; SYSCALL_MODULE(ddfenabled, &ddfenabled_offset, &ddfenabled_sysent, ddload, NULL); the user code needs something like: static int ddfenabled_sysno = 0; /* * Module init */ int rlu_init(void) { struct module_stat mstat; int modid; /* Find some dedup-related syscalls */ if (ddfenabled_sysno == 0) { mstat.version = sizeof(mstat); if ((modid = modfind("ddfenabled")) == -1 || modstat(modid, &mstat) == -1) { return -1; } ddfenabled_sysno = mstat.data.intval; } return 0; }