From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53D6ACAC5A5 for ; Wed, 24 Sep 2025 10:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernelnewbies.org; s=mail; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pPwocqpnWp8s5wY5jhzs1x49FBeXkYQ0CrV9DlmT15s=; b=XA7iYFyizRHV6TJctlzZX+xnAs +lHeVPTosgfG7o2FdSUXvJkRE8bFfM8udjgK4/bFdtXdEha8j26KmBWXGWk4FjRhsE7/mVtcwmvk2 Y1Gjn4hnQu6jUyBF5U8ita7U95Ci8QX2J63ri/1sdOiOpZkGY/qNnHrX58w3CX3SY+qYCbfdIQbzK um6ffvYmHx3Hz7YG05WlB0CrOgtFfhAHY0r5lTqnAuNBcrxpdkbyyAdOo+8/8xzZzLZDWlHFxLyUd ZzrtneLUIvahm7rKHNkI4fNb3Szq6smdfiHAm8xCl2qQYWu/xFcVsmAGTzh3SGwnmG278kIb0489u bM2CTYMA==; Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.97.1) (envelope-from ) id 1v1Ml3-000000007Zp-1UKr for kernelnewbies@archiver.kernel.org; Wed, 24 Sep 2025 06:29:57 -0400 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1v1Mim-000000005RW-44Vz for kernelnewbies@kernelnewbies.org; Wed, 24 Sep 2025 06:27:37 -0400 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 18B9F14000F9; Wed, 24 Sep 2025 06:27:36 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 24 Sep 2025 06:27:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1758709656; x=1758796056; bh=ZgAAmR9xcI 0d8Qv6LqI18BvaKuQX67qp2mG7pttSWbo=; b=DP04ndPNuwxo7U8KvO3Jvp357t Ow7k1fl6P8csyYNnyjpg9Q+/sgE8rUWp0r5H005Hfz4us+85Kwnx1hsgMR0qRMWK Rhf/jcGu99CoQlhW8CKqPX8nAEdqw93pgmZvi28+t/WHy50TLQu8wyoElMeGKCjh JTRhdyEu8/IzQ7P1jKwIIpprJwrmOZC1EsZWyCQpG3Yai7uYki+dgg7tXbNj3nf4 gor5E8SMV2qNe+Eyem1wC/6/8gH4nn5UF436o0g+PEPXzcDvgxMjZGQ6XHxX3qlx UtbQnwmMM1iT8aOPGhdy4uYEIa/9e40eFx2bTgBBs4nBFl/RM9HZhuHrsSFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1758709656; x=1758796056; bh=ZgAAmR9xcI0d8Qv6LqI18BvaKuQX67qp2mG 7pttSWbo=; b=QtHCtdcfzsrLE9zAo4/QwNBwp71KenHVQEE3dbAxeUittVMxqKo 26l8xzSBQUtSeCMEhnbrd//aoA5aBPuctu8Ij43OVfNPokFjFA7AyoNrpoEoiv/X zojhNo752ovhFuRmyrAe2SM9xoHmevWOqLq0BzjMpkCGIZiW7p/E+bD5MJnB3EVV AeACx+dD9D6asIBRX7rfrSEBrWBldPec6yFYNyDF/Lds7vYW0zeW3VflmLcem755 1H6SDqarFdQyDS3rQ3jlTQ+1KDL4EFmu0HQruPKo0XJ3wxdGZ05p7QbBIaqh9o5h hLx6mZft1yGnRPxnfJvBLNGtxJ4Jununa3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeifeefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggujgesthdtredttd dtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecu ggftrfgrthhtvghrnhepheegvdevvdeljeeugfdtudduhfekledtiefhveejkeejuefhtd eufefhgfehkeetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepghhrvghgsehkrhhorghhrdgtohhmpdhnsggprhgtphhtthhopeegpdhmohguvg epshhmthhpohhuthdprhgtphhtthhopeguvghvvghlohhpmhgvnhhtsehrvggurghrihhl rdhmvgdprhgtphhtthhopehkvghrnhgvlhhnvgifsghivghssehkvghrnhgvlhhnvgifsg hivghsrdhorhhg X-ME-Proxy: Feedback-ID: i787e41f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 Sep 2025 06:27:34 -0400 (EDT) Date: Wed, 24 Sep 2025 12:27:30 +0200 From: Greg KH To: Fabio Subject: Re: Rust: how to implement file_operations for a misc device? Message-ID: <2025092445-editor-wobbling-1f26@gregkh> References: <240f21b8-6d0c-4ce0-8dbb-2eea3c6d6b1d@redaril.me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <240f21b8-6d0c-4ce0-8dbb-2eea3c6d6b1d@redaril.me> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org On Tue, Sep 23, 2025 at 06:47:25PM +0200, Fabio wrote: > Hello, > > brand-new kernel newbie here. I'm interested in the Rust side of the kernel. > To get acquainted, I'm following the Linux Driver Development book, 3rd > edition, also integrating it with modern documentation and best practices > (or at least I hope so). > > I'm developing the scull module on top of the > `kernel::miscdevice::MiscDevice` trait. Where I'm stuck at is the lack of > the `kernel::file::Operations` trait [1], that most online resources refer > to. I need such trait to implement read and write operations for the misc > device. AFAIU, this trait used to exist but it's no longer in the mainline > codebase [2]. Also, `kernel::miscdevice::MiscdeviceVTable` is private inside > the miscdevice module, so there's no way I can somehow extend it. > > Is there any workaround for what I want to achieve, or is ioctl the only > allowed interface to misc devices in Rust? Please see the rust sample misc driver that is right now in linux-next, it shows how to use the read and write iter functions, which should be all that you need. Specifically look at commit e5b0d7da941a ("samples: rust_misc_device: Expand the sample to support read()ing from userspace"), which shows how this can be done. Yes, this is a bit different than the traditional "read/write" callbacks, as documented in the device driver's book, but things have moved on in the decades since we wrote that :) The changes for this will be showing up in the next kernel release (i.e. 6.18). hope this helps, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies