Re: How to tell if a vnode resides in a usb mass storage device?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kG9XQlpEeqz+Ml/hU+qyYNJR8JX13TffTvIbls+bxCc=; b=SmeZTj/+98Ef6KXs9FN1Q7A/ML7F8i3zFia8/Bo7ew/SlD7drH+nGGxJ79I/i+Vmr2 jur7olosxu8OqebkJxYbHmYXY+hoZFVJyey9HNbx6Ui13Z6a7GqKSrWSGyYiltZkT/OJ ImV2zJihzMrMGjN65YQelDaCvFlBMNlWeIkFDKXXpyGJqbOIYELkFVRhG/U0LLBJui6p +dTudFbMPvHNLzilRR8+MSV37S8fFFd9C25LO2wO2eL4hcYgEuYn8T6b4MEqZNUqNRor EjFSO/PpnlxWr4MrbWe7SZlqe0LV0eWI8sD0BEy+Tsam2eBxSNZYta2QvD4AVkBBdov0 M7hg== You can get the vnode's fsid and decide whether it matches that of the usb device. uint64_t getVnodeFsid(const vfs_context_t ctx, const vnode_t vp) { struct vnode_attr vap; VATTR_INIT(&vap); VATTR_WANTED(&vap, va_fileid); vnode_getattr(vp, &vap, ctx); return (vap.va_fileid); } now you need to know what's the usb mount fsid which can be done in user-space and passed to your driver. you can use getmntinfo command and iterate the mount drives until you get to your desired device (by checking f_mntonname) Irad On Tue, Sep 25, 2018 at 10:58 AM Haohao Lee <hayatelee@gmail.com> wrote:
Hi folks,
We need find if a vnode (file) is from a usb drive. More generally, do we have a way to get device info from a vnode.
It can be done easily in Linux via super_block stuff, but there is no such thing in xnu.
Any suggestion is appreciated!
Hao _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-kernel/iradization%40gmail.co...
This email sent to iradization@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Irad K