From owner-freebsd-drivers@freebsd.org Thu Oct 10 05:50:09 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 DCEE7147330; Thu, 10 Oct 2019 05:50:09 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from mx0b-00154904.pphosted.com (mx0b-00154904.pphosted.com [148.163.137.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 46pgCh3Shjz4c3X; Thu, 10 Oct 2019 05:50:07 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from pps.filterd (m0170394.ppops.net [127.0.0.1]) by mx0b-00154904.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9A5nwWb018619; Thu, 10 Oct 2019 01:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dell.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=smtpout1; bh=87330nmkVMd+kBTD8HOCex37+P1E6wrm1Z4EkFjt7mc=; b=EGFYq4TnIJTrTcSo+2HTovpkeb6kPJIfQHBZMsKD+4NRXp7gE9fG3h7pihK6mOYUfOpp FjI/jLsp+A9OMZk5nr8LMkkPkDw9zAMIdJBDk8ZhpYQobNNlPYHh92wN45XWjX39DdhC F6x6JKweU9BVxpLcsgT01sUh5nZL0TfVMv6BGjU7Edpnb0rXHvc2ZUzjLihm4QMKKxY2 QVc72HuGbcGFU0eBrx2PWbx9+cxDE7BpgDND1q5usEAOlV/SF888zo2MDvAfsmZsXh0i 3N1kYTxM2Ky0gSDoynDbjLj5uzcvRj+STrmfqWpIdl/x6bYSmyFDohVJCMmg/yOpkfD+ 3w== Received: from mx0a-00154901.pphosted.com (mx0a-00154901.pphosted.com [67.231.149.39]) by mx0b-00154904.pphosted.com with ESMTP id 2venr7yceb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Oct 2019 01:50:04 -0400 Received: from pps.filterd (m0134746.ppops.net [127.0.0.1]) by mx0a-00154901.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9A5ltaB161159; Thu, 10 Oct 2019 01:50:03 -0400 Received: from ausc60ps301.us.dell.com (ausc60ps301.us.dell.com [143.166.148.206]) by mx0a-00154901.pphosted.com with ESMTP id 2vhwrfruue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Oct 2019 01:50:03 -0400 X-LoopCount0: from 10.166.137.63 X-PREM-Routing: D-Outbound X-IronPort-AV: E=Sophos;i="5.60,349,1549951200"; d="scan'208,217";a="1361392574" From: To: , CC: Subject: a issue about getting a devfs node's fullpath Thread-Topic: a issue about getting a devfs node's fullpath Thread-Index: AdV/GGVUhjnLmzB6SsidzxkwZYw4IQ== Date: Thu, 10 Oct 2019 05:49:55 +0000 Message-ID: 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-10T05:49:54.0280618Z; 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] MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-10_03:2019-10-08,2019-10-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 malwarescore=0 adultscore=0 priorityscore=1501 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=939 bulkscore=0 clxscore=1031 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910100054 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 clxscore=1031 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910100054 X-Rspamd-Queue-Id: 46pgCh3Shjz4c3X X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dell.com header.s=smtpout1 header.b=EGFYq4Tn; dmarc=pass (policy=none) header.from=dell.com; spf=pass (mx1.freebsd.org: domain of Zhichao1.Li@dell.com designates 148.163.137.20 as permitted sender) smtp.mailfrom=Zhichao1.Li@dell.com X-Spamd-Result: default: False [-5.89 / 15.00]; ARC_NA(0.00)[]; SUBJECT_ENDS_SPACES(0.50)[]; R_DKIM_ALLOW(-0.20)[dell.com:s=smtpout1]; HAS_XOIP(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_FIVE(0.00)[5]; R_SPF_ALLOW(-0.20)[+ip4:148.163.137.20]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; 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.01), ipnet: 148.163.137.0/24(0.01), asn: 22843(-1.42), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[20.137.163.148.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:22843, ipnet:148.163.137.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; WHITELIST_SPF_DKIM(-3.00)[dell.com:d:+,dell.com:s:+] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 10 Oct 2019 05:50:09 -0000 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_ful= lpath', when dealing with things like '/dev/null' or '/dev/usb/1.0.1', it w= orks well. However when dealing a node under more than 2 sub directories (e.g. /dev/bu= s/usb/001/002) which I made by calling 'make_dev_s' , it goes a little bit= different, I got a string "/dev/bus/usb/bus/usb/001/002" And I found the function 'devfs_vptocnp' gets the string wrongly when deali= ng multi slashes path string, I have remark the code as followed and put so= me comments would you please take a look, and tell me what the purpose this func pass t= he string that way? static int devfs_vptocnp(struct vop_vptocnp_args *ap) { struct vnode *vp =3D ap->a_vp; struct vnode **dvp =3D ap->a_vpp; struct devfs_mount *dmp; char *buf =3D ap->a_buf; int *buflen =3D ap->a_buflen; struct devfs_dirent *dd, *de; int i, error; dmp =3D VFSTODEVFS(vp->v_mount); error =3D devfs_populate_vp(vp); if (error !=3D 0) return (error); i =3D *buflen; dd =3D vp->v_data; 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)); /* * when dealing with VCHR * the element 'si_name' already * holds the full path string * except rootdir, why not just go * to the rootdir? */ 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_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; goto finished; } *buflen =3D i; de =3D devfs_parent_dirent(de); if (de =3D=3D NULL) { error =3D ENOENT; goto finished; } mtx_lock(&devfs_de_interlock); *dvp =3D de->de_vnode; if (*dvp !=3D NULL) { VI_LOCK(*dvp); mtx_unlock(&devfs_de_interlock); vholdl(*dvp); VI_UNLOCK(*dvp); vref(*dvp); vdrop(*dvp); } else { mtx_unlock(&devfs_de_interlock); error =3D ENOENT; } finished: sx_xunlock(&dmp->dm_lock); return (error); } From owner-freebsd-drivers@freebsd.org Thu Oct 10 15:39:45 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 5460B141F98; Thu, 10 Oct 2019 15:39:45 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46pwJ04sc8z4Fhk; Thu, 10 Oct 2019 15:39:44 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x9AFdXhp011691 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 10 Oct 2019 18:39:36 +0300 (EEST) (envelope-from kib@freebsd.org) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x9AFdXhp011691 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x9AFdWbZ011690; Thu, 10 Oct 2019 18:39:32 +0300 (EEST) (envelope-from kib@freebsd.org) X-Authentication-Warning: tom.home: kostik set sender to kib@freebsd.org using -f Date: Thu, 10 Oct 2019 18:39:32 +0300 From: Konstantin Belousov To: Zhichao1.Li@dell.com Cc: freebsd-fs@freebsd.org, freebsd-drivers@freebsd.org, Shunchao.Hu@dell.com Subject: Re: a issue about getting a devfs node's fullpath Message-ID: <20191010153932.GO44691@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 46pwJ04sc8z4Fhk X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.79 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.79)[-0.795,0]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; NEURAL_HAM_LONG(-1.00)[-0.998,0] 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: Thu, 10 Oct 2019 15:39:45 -0000 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_fullpath', 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 bit different, I got a string "/dev/bus/usb/bus/usb/001/002" > And I found the function 'devfs_vptocnp' gets the string wrongly when 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 purpose 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 != 0) return (error); - i = *buflen; + if (vp->v_type != VCHR && vp->v_type != VDIR) { + error = ENOENT; + goto finished; + } + dd = vp->v_data; + if (vp->v_type == VDIR && dd == dmp->dm_rootdir) { + *dvp = vp; + vref(*dvp); + goto finished; + } - if (vp->v_type == VCHR) { - i -= strlen(dd->de_cdp->cdp_c.si_name); - if (i < 0) { - error = ENOMEM; - goto finished; - } - bcopy(dd->de_cdp->cdp_c.si_name, buf + i, - strlen(dd->de_cdp->cdp_c.si_name)); - de = dd->de_dir; - } else if (vp->v_type == VDIR) { - if (dd == dmp->dm_rootdir) { - *dvp = vp; - vref(*dvp); - goto finished; - } - i -= dd->de_dirent->d_namlen; - if (i < 0) { - error = ENOMEM; - goto finished; - } - bcopy(dd->de_dirent->d_name, buf + i, - dd->de_dirent->d_namlen); - de = dd; - } else { - error = ENOENT; + i = *buflen; + i -= dd->de_dirent->d_namlen; + if (i < 0) { + error = ENOMEM; goto finished; } + bcopy(dd->de_dirent->d_name, buf + i, dd->de_dirent->d_namlen); *buflen = i; - de = devfs_parent_dirent(de); + de = devfs_parent_dirent(dd); if (de == NULL) { error = ENOENT; goto finished; 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; From owner-freebsd-drivers@freebsd.org Fri Oct 11 08:28:52 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 C33F61429A0; Fri, 11 Oct 2019 08:28:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46qLhM6mkqz4BB2; Fri, 11 Oct 2019 08:28:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x9B8SdJi050252 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 11 Oct 2019 11:28:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x9B8SdJi050252 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x9B8ScYm050251; Fri, 11 Oct 2019 11:28:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 11 Oct 2019 11:28:38 +0300 From: Konstantin Belousov To: Zhichao1.Li@dell.com Cc: freebsd-fs@freebsd.org, freebsd-drivers@freebsd.org, Shunchao.Hu@dell.com Subject: Re: a issue about getting a devfs node's fullpath Message-ID: <20191011082838.GR44691@kib.kiev.ua> References: <20191010153932.GO44691@kib.kiev.ua> <54b7173c96df43689de04f848ca86de6@KULX13MDC103.APAC.DELL.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54b7173c96df43689de04f848ca86de6@KULX13MDC103.APAC.DELL.COM> User-Agent: Mutt/1.12.2 (2019-09-21) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 46qLhM6mkqz4BB2 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(0.00)[ip: (-2.65), ipnet: 2001:470::/32(-4.57), asn: 6939(-3.40), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] 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 08:28:52 -0000 On Fri, Oct 11, 2019 at 02:23:14AM +0000, Zhichao1.Li@dell.com wrote: > Hello > Thank you for your time > Unfortunately it does not work, how about this way? It does not work in which way ? I tried it and it worked as expected. Your patch is wrong, VOP_VPTOCNP() must return parent vnode, if any. > > --- 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 = 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 = dmp->dm_rootdir; > } else if (vp->v_type == VDIR) { > if (dd == dmp->dm_rootdir) { > *dvp = 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 = dd; > + /* > + * when dealing with VDIR > + * get its parent > + */ > + de = devfs_parent_dirent(dd); > } else { > error = ENOENT; > goto finished; > } > *buflen = i; > - de = devfs_parent_dirent(de); > + /*no need to get another parent*/ > if (de == NULL) { > error = ENOENT; > goto finished; > > another thing is this func is called by many modules, I want to ensure modifying the func this way will not impact other modules and not bring some bugs, would you be so kind to help me out? > > thank you > > -----Original Message----- > From: Konstantin Belousov > 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] > > 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_fullpath', 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 bit different, I got a string "/dev/bus/usb/bus/usb/001/002" > > And I found the function 'devfs_vptocnp' gets the string wrongly when > > 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 purpose 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 != 0) > return (error); > > - i = *buflen; > + if (vp->v_type != VCHR && vp->v_type != VDIR) { > + error = ENOENT; > + goto finished; > + } > + > dd = vp->v_data; > + if (vp->v_type == VDIR && dd == dmp->dm_rootdir) { > + *dvp = vp; > + vref(*dvp); > + goto finished; > + } > > - if (vp->v_type == VCHR) { > - i -= strlen(dd->de_cdp->cdp_c.si_name); > - if (i < 0) { > - error = ENOMEM; > - goto finished; > - } > - bcopy(dd->de_cdp->cdp_c.si_name, buf + i, > - strlen(dd->de_cdp->cdp_c.si_name)); > - de = dd->de_dir; > - } else if (vp->v_type == VDIR) { > - if (dd == dmp->dm_rootdir) { > - *dvp = vp; > - vref(*dvp); > - goto finished; > - } > - i -= dd->de_dirent->d_namlen; > - if (i < 0) { > - error = ENOMEM; > - goto finished; > - } > - bcopy(dd->de_dirent->d_name, buf + i, > - dd->de_dirent->d_namlen); > - de = dd; > - } else { > - error = ENOENT; > + i = *buflen; > + i -= dd->de_dirent->d_namlen; > + if (i < 0) { > + error = ENOMEM; > goto finished; > } > + bcopy(dd->de_dirent->d_name, buf + i, dd->de_dirent->d_namlen); > *buflen = i; > - de = devfs_parent_dirent(de); > + de = devfs_parent_dirent(dd); > if (de == NULL) { > error = ENOENT; > goto finished; From owner-freebsd-drivers@freebsd.org Fri Oct 11 09:21:57 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 B55D6144FA2; Fri, 11 Oct 2019 09:21:57 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from mx0b-00154904.pphosted.com (mx0b-00154904.pphosted.com [148.163.137.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 46qMsc59PHz4Fnw; Fri, 11 Oct 2019 09:21:56 +0000 (UTC) (envelope-from Zhichao1.Li@dell.com) Received: from pps.filterd (m0170398.ppops.net [127.0.0.1]) by mx0b-00154904.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B9AMh1000485; Fri, 11 Oct 2019 05:21:55 -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=yLSU1q52zL6Lo2hsxDf/UXeQm1y1XY5Uz5jEuj7bXYg=; b=HCSYckYTgP1ZptjdzzKwo7wptIwMKW6DkufxDGWWFsa2QPa/XPbTURMixOH3WIlm7B6q NCF0A2M6kwVS1xi3ZukmcUw65T1vvUkvqEEQM3pXXDrfLhS2v8BXDc/u8OynYk4e76Wr MTLoADmjnrqwdkg/sew+b/GskduCjfo4Ene2dSOPlsUNoDo+wAFUMaPT+HVeSr0FD1um S9sqhkvFswR3XQ6ATnAfU1U2emEvVypTAginCaQ8mzh2gkPljXZg8KK5Kasyla4+zvPE yLNLmUPovgm/D0l3ZjtG1V2v91K4ikFqupF86H1EaqZZO2tNVZaeG8/D/e413GUiMD5d dQ== Received: from mx0b-00154901.pphosted.com (mx0b-00154901.pphosted.com [67.231.157.37]) by mx0b-00154904.pphosted.com with ESMTP id 2vepdawbju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2019 05:21:55 -0400 Received: from pps.filterd (m0144102.ppops.net [127.0.0.1]) by mx0b-00154901.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9B97rHl045782; Fri, 11 Oct 2019 05:21:55 -0400 Received: from ausc60pc101.us.dell.com (ausc60pc101.us.dell.com [143.166.85.206]) by mx0b-00154901.pphosted.com with ESMTP id 2vjp498uex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 05:21:55 -0400 X-LoopCount0: from 10.166.135.96 X-PREM-Routing: D-Outbound X-IronPort-AV: E=Sophos;i="5.60,349,1549951200"; d="scan'208";a="1479216523" 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///jsACAAJR8UA== Date: Fri, 11 Oct 2019 09:21:49 +0000 Message-ID: <512acd5891c94cb49bba6df379202bc6@KULX13MDC103.APAC.DELL.COM> References: <20191010153932.GO44691@kib.kiev.ua> <54b7173c96df43689de04f848ca86de6@KULX13MDC103.APAC.DELL.COM> <20191011082838.GR44691@kib.kiev.ua> In-Reply-To: <20191011082838.GR44691@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-11T09:21:48.1806758Z; 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_06:2019-10-10,2019-10-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 adultscore=0 clxscore=1015 malwarescore=0 bulkscore=0 spamscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110088 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 bulkscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910110088 X-Rspamd-Queue-Id: 46qMsc59PHz4Fnw X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dell.com header.s=smtpout1 header.b=HCSYckYT; dmarc=pass (policy=none) header.from=dell.com; spf=pass (mx1.freebsd.org: domain of Zhichao1.Li@dell.com designates 148.163.137.20 as permitted sender) smtp.mailfrom=Zhichao1.Li@dell.com X-Spamd-Result: default: False [-6.40 / 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.137.20]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; WHITELIST_SPF_DKIM(-3.00)[dell.com:d:+,dell.com:s:+]; 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.30)[ip: (0.00), ipnet: 148.163.137.0/24(0.01), asn: 22843(-1.44), country: US(-0.05)]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_LOW(-0.10)[20.137.163.148.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:22843, ipnet:148.163.137.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; DWL_DNSWL_NONE(0.00)[dell.com.dwl.dnswl.org : 127.0.9.0] 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 09:21:57 -0000 sorry my bad, your pitch works exactly, thank you so much -----Original Message----- From: Konstantin Belousov =20 Sent: Friday, October 11, 2019 4:29 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 Fri, Oct 11, 2019 at 02:23:14AM +0000, Zhichao1.Li@dell.com wrote: > Hello > Thank you for your time > Unfortunately it does not work, how about this way? It does not work in which way ? I tried it and it worked as expected. Your patch is wrong, VOP_VPTOCNP() must return parent vnode, if any. >=20 > --- 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; >=20 > another thing is this func is called by many modules, I want to ensure mo= difying the func this way will not impact other modules and not bring some = bugs, would you be so kind to help me out? >=20 > thank you >=20 > -----Original Message----- > From: Konstantin Belousov > Sent: Thursday, October 10, 2019 11:40 PM > To: Li, Zhichao1 > Cc: freebsd-fs@freebsd.org; freebsd-drivers@freebsd.org; Hu, Shunchao=20 > > Subject: Re: a issue about getting a devfs node's fullpath >=20 >=20 > [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= _fullpath', 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. /de= v/bus/usb/001/002) which I made by calling 'make_dev_s' , it goes a little= bit different, I got a string "/dev/bus/usb/bus/usb/001/002" > > And I found the function 'devfs_vptocnp' gets the string wrongly=20 > > when dealing multi slashes path string, I have remark the code as follo= wed and put some comments would you please take a look, and tell me what th= e purpose this func pass the string that way? >=20 > Try this. Not tested. >=20 > diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c=20 > 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;