From owner-freebsd-drivers@freebsd.org Fri Oct 11 02:23:24 2019 Return-Path: Delivered-To: freebsd-drivers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F12A139124; Fri, 11 Oct 2019 02:23:24 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from mx0a-00154904.pphosted.com (mx0a-00154904.pphosted.com [148.163.133.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46qBZg1YXdz3MnF; Fri, 11 Oct 2019 02:23:22 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from pps.filterd (m0170393.ppops.net [127.0.0.1]) by mx0a-00154904.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B2JjBR020846; Thu, 10 Oct 2019 22:23:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=smtpout1; bh=InbY9COoYyOr86DfZ/GPeE68e0G4EjQ8M70ZDt9sbzk=; b=yL0bPl3nvn78JeroKvvmgdO5Ic3nh7qXT/AZLfOs0IMaN6PvWPTSdClKnofeZME7in5K RLyXWS5I1jNy5oUepqDRCMtoYoFviNPsbQ+p3FsHaD+eWL0YPowRRUZTpBlqVLx7S41Z E5Oe/EnGHsBVft965xKx5/Vyx4zc084vUIeYMfrD3fjXP2Sgb2m7dm6kYWwMwOgJHinP iZ6LZh+bD9YhNakMSqmzKRgQrMbCRErOgwCC8uLeaN8VUdUDKW+fPhaim5xDLO+yeOL9 YNn4gRmhJfRVz9H6l0r+s/9hdi9co6L/I32ihtVJ6uuXQTPtd2ScG4G3fIVmIsMOYK74 MQ== Received: from mx0b-00154901.pphosted.com (mx0b-00154901.pphosted.com [67.231.157.37]) by mx0a-00154904.pphosted.com with ESMTP id 2vepgkccds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Oct 2019 22:23:19 -0400 Received: from pps.filterd (m0089483.ppops.net [127.0.0.1]) by mx0b-00154901.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B2Mw8r118022; Thu, 10 Oct 2019 22:23:18 -0400 Received: from ausc60pc101.us.dell.com (ausc60pc101.us.dell.com [143.166.85.206]) by mx0b-00154901.pphosted.com with ESMTP id 2vjdd8jatd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Oct 2019 22:23:18 -0400 X-LoopCount0: from 10.166.136.210 X-PREM-Routing: D-Outbound X-IronPort-AV: E=Sophos;i="5.60,349,1549951200"; d="scan'208";a="1479036184" From: To: CC: , , Subject: RE: a issue about getting a devfs node's fullpath Thread-Topic: a issue about getting a devfs node's fullpath Thread-Index: AQHVf4DyNH+n5oqc4Ea+l7PCusRzvadUsvRA Date: Fri, 11 Oct 2019 02:23:14 +0000 Message-ID: <54b7173c96df43689de04f848ca86de6@KULX13MDC103.APAC.DELL.COM> References: <20191010153932.GO44691@kib.kiev.ua> In-Reply-To: <20191010153932.GO44691@kib.kiev.ua> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Enabled=True; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_SiteId=945c199a-83a2-4e80-9f8c-5a91be5752dd; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Owner=Zhichao_Li1@Dell.com; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_SetDate=2019-10-11T02:23:12.8497933Z; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Name=External Public; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Application=Microsoft Azure Information Protection; MSIP_Label_17cb76b2-10b8-4fe1-93d4-2202842406cd_Extended_MSFT_Method=Manual; aiplabel=External Public x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.93.131.111] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-11_01:2019-10-10,2019-10-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 clxscore=1011 mlxscore=0 phishscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110019 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 adultscore=0 spamscore=0 priorityscore=1501 clxscore=1011 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110018 X-Rspamd-Queue-Id: 46qBZg1YXdz3MnF X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dell.com header.s=smtpout1 header.b=yL0bPl3n; dmarc=pass (policy=none) header.from=dell.com; spf=pass (mx1.freebsd.org: domain of Zhichao1.Li@dell.com designates 148.163.133.20 as permitted sender) smtp.mailfrom=Zhichao1.Li@dell.com X-Spamd-Result: default: False [-6.39 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[dell.com:s=smtpout1]; HAS_XOIP(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_FIVE(0.00)[5]; R_SPF_ALLOW(-0.20)[+ip4:148.163.133.20]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DWL_DNSWL_NONE(0.00)[dell.com.dwl.dnswl.org : 127.0.9.0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[dell.com:+]; DMARC_POLICY_ALLOW(-0.50)[dell.com,none]; FROM_NO_DN(0.00)[]; IP_SCORE(-0.29)[ip: (0.05), ipnet: 148.163.133.0/24(0.02), asn: 26211(-1.45), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[20.133.163.148.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:26211, ipnet:148.163.133.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; WHITELIST_SPF_DKIM(-3.00)[dell.com:d:+,dell.com:s:+] X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Oct 2019 02:23:24 -0000 Hello Thank you for your time Unfortunately it does not work, how about this way? --- a/src/sys/fs/devfs/devfs_vnops.c +++ b/src/sys/fs/devfs/devfs_vnops.c @@ -293,7 +293,14 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) } bcopy(dd->de_cdp->cdp_c.si_name, buf + i, strlen(dd->de_cdp->cdp_c.si_name)); - de =3D dd->de_dir; + /* + * when dealing with VCHR + * the element 'si_name' already + * holds the full path string + * except rootdir, so just go + * to the rootdir + */ + de =3D dmp->dm_rootdir; } else if (vp->v_type =3D=3D VDIR) { if (dd =3D=3D dmp->dm_rootdir) { *dvp =3D vp; @@ -307,13 +314,17 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) } bcopy(dd->de_dirent->d_name, buf + i, dd->de_dirent->d_namlen); - de =3D dd; + /* + * when dealing with VDIR + * get its parent + */ + de =3D devfs_parent_dirent(dd); } else { error =3D ENOENT; goto finished; } *buflen =3D i; - de =3D devfs_parent_dirent(de); + /*no need to get another parent*/ if (de =3D=3D NULL) { error =3D ENOENT; goto finished; another thing is this func is called by many modules, I want to ensure modi= fying the func this way will not impact other modules and not bring some bu= gs, would you be so kind to help me out? thank you=20 -----Original Message----- From: Konstantin Belousov =20 Sent: Thursday, October 10, 2019 11:40 PM To: Li, Zhichao1 Cc: freebsd-fs@freebsd.org; freebsd-drivers@freebsd.org; Hu, Shunchao Subject: Re: a issue about getting a devfs node's fullpath [EXTERNAL EMAIL]=20 On Thu, Oct 10, 2019 at 05:49:55AM +0000, Zhichao1.Li@dell.com wrote: > Dear freebsd developers > I know you're swamped, so I'll be brief. > I am trying to get a node's full under /dev by calling the function 'vn_f= ullpath', when dealing with things like '/dev/null' or '/dev/usb/1.0.1', it= works well. > However when dealing a node under more than 2 sub directories (e.g. /dev/= bus/usb/001/002) which I made by calling 'make_dev_s' , it goes a little b= it different, I got a string "/dev/bus/usb/bus/usb/001/002" > And I found the function 'devfs_vptocnp' gets the string wrongly when=20 > dealing multi slashes path string, I have remark the code as followed and= put some comments would you please take a look, and tell me what the purpo= se this func pass the string that way? Try this. Not tested. diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index = 3b80c68e309..f20b466d88b 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -284,38 +284,27 @@ devfs_vptocnp(struct vop_vptocnp_args *ap) if (error !=3D 0) return (error); =20 - i =3D *buflen; + if (vp->v_type !=3D VCHR && vp->v_type !=3D VDIR) { + error =3D ENOENT; + goto finished; + } + dd =3D vp->v_data; + if (vp->v_type =3D=3D VDIR && dd =3D=3D dmp->dm_rootdir) { + *dvp =3D vp; + vref(*dvp); + goto finished; + } =20 - if (vp->v_type =3D=3D VCHR) { - i -=3D strlen(dd->de_cdp->cdp_c.si_name); - if (i < 0) { - error =3D ENOMEM; - goto finished; - } - bcopy(dd->de_cdp->cdp_c.si_name, buf + i, - strlen(dd->de_cdp->cdp_c.si_name)); - de =3D dd->de_dir; - } else if (vp->v_type =3D=3D VDIR) { - if (dd =3D=3D dmp->dm_rootdir) { - *dvp =3D vp; - vref(*dvp); - goto finished; - } - i -=3D dd->de_dirent->d_namlen; - if (i < 0) { - error =3D ENOMEM; - goto finished; - } - bcopy(dd->de_dirent->d_name, buf + i, - dd->de_dirent->d_namlen); - de =3D dd; - } else { - error =3D ENOENT; + i =3D *buflen; + i -=3D dd->de_dirent->d_namlen; + if (i < 0) { + error =3D ENOMEM; goto finished; } + bcopy(dd->de_dirent->d_name, buf + i, dd->de_dirent->d_namlen); *buflen =3D i; - de =3D devfs_parent_dirent(de); + de =3D devfs_parent_dirent(dd); if (de =3D=3D NULL) { error =3D ENOENT; goto finished;