From owner-freebsd-hackers@freebsd.org Sun Dec 3 17:13:57 2017 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 A9641E56F65 for ; Sun, 3 Dec 2017 17:13:57 +0000 (UTC) (envelope-from embaudarm@gmail.com) Received: from mail-oi0-x22e.google.com (mail-oi0-x22e.google.com [IPv6:2607:f8b0:4003:c06::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70B6D7F428 for ; Sun, 3 Dec 2017 17:13:57 +0000 (UTC) (envelope-from embaudarm@gmail.com) Received: by mail-oi0-x22e.google.com with SMTP id 184so10243316oii.2 for ; Sun, 03 Dec 2017 09:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=TsW4ex1hawdXMpUcg3TOiW4x2E1jb/6ZXWRH6hKEYRo=; b=JzozVMC0zdGB6SG+VYd8CrPPP8ZJMvgcwG0JPR0pmyhGky5uXn3zA/rymfdOVD25cf E5XAuc3mZlIkzDn2zenut3da6xV+qdbOidEszWUHsYuityFDgsWVYP2p+2MvJpFQMK/N EUG1i39Yiabp0yVC+czB/d7F14sf7+rXF9egv6/kZcMiI0XSgjo453RRzRLG20YP38Kw lPV9BDipBsqfLyZc2rLGP7L4gBvlg5zblQ5KdcekWTQQFl47iRJjIvCChNC9daXpJS8c 0xEH+13orbkwSRfIeNf+wHg08cP+pt+ILyhGWkksrPxq/+frgdDSfsuSHaiuevthjyT7 M7JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=TsW4ex1hawdXMpUcg3TOiW4x2E1jb/6ZXWRH6hKEYRo=; b=JnRhlmPv3kbR7ide/bvqO72MI1rh7+CaVpNionIYlW39Osmlc+RNvVMh6ZM6oGbXMB min9LLnau1en1nudfIyHSkK8y1QRmbArYZ1H1yVO+WV/ucyte/jls0oBHi5/+AUgU+pi 1ARWfOLrqRallljn5MSR+g4k0B7dNDLSGaf2jG7FbBuBAj5YpzXM+lMJfghlqC/eHb5V lpsuYdbvMdy6KaA27WWvHOdctfbTZzrOqfUhm1Fn1zCUNjlD7Yo8hkmxWfb5AyLxCTc8 8+Y3c9/YHEuS3NsnB2Q6xQoV29clF6hdlOs2HJsUN2lcIhAmVCA2qdeWQP9OdkNLI4m7 mPpg== X-Gm-Message-State: AJaThX7XczqE7FyKG7vGZYu7/ZTnQ6pBD/gKsD6qANRj1ISbD0iJdhtV kuvr2nSmHEvkYcgPjaZKkhtVQl7L40CZw4Y4HMtIYBlS X-Google-Smtp-Source: AGs4zMYxz+q/hos3xutCm8I02j01HBOsA1ZLd/MAHgqG4dSfJuFA5wvHpy41gnqztTWJJk87DHfCJ4MP9emRN2v5RBg= X-Received: by 10.202.73.134 with SMTP id w128mr11622222oia.11.1512321236630; Sun, 03 Dec 2017 09:13:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.39.47 with HTTP; Sun, 3 Dec 2017 09:13:16 -0800 (PST) From: Lee D Date: Sun, 3 Dec 2017 12:13:16 -0500 Message-ID: Subject: How do I make my device driver respond to lseek? To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Dec 2017 17:13:57 -0000 Hi, I've been trying to figure out how to make my device driver respond to lseek(). There doesn't seem to be an appropriate entry in the cdevsw structure (in src/sys/sys/conf.h). Obviously I can make an ioctl() call for this (and I have, in the interim), but I'd like to do it it the right way. I have a feeling like I am misunderstanding some critical abstraction layer... But at some point the device driver must be told what position to start reading from/writing to, right? FWIW, this is a device driver interface to a SPI flash in my custom ARM embedded system. I need to be able to locate to a point in the flash to read and write my app config info, without disturbing my boot loader. I want to be able to write code like this: int fd = open ("/dev/my_spi_flash0", O_RDWR); lseek(fd, 0x10000, SEEK_SET); write(fd, buf, 100); close(fd); Does anyone know the proper way to implement lseek?