ntfs_subr.c (60041) | ntfs_subr.c (66615) |
---|---|
1/* $NetBSD: ntfs_subr.c,v 1.23 1999/10/31 19:45:26 jdolecek Exp $ */ 2 3/*- 4 * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* $NetBSD: ntfs_subr.c,v 1.23 1999/10/31 19:45:26 jdolecek Exp $ */ 2 3/*- 4 * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/fs/ntfs/ntfs_subr.c 60041 2000-05-05 09:59:14Z phk $ | 28 * $FreeBSD: head/sys/fs/ntfs/ntfs_subr.c 66615 2000-10-04 01:29:17Z jasone $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/types.h> 33#include <sys/systm.h> 34#include <sys/namei.h> 35#include <sys/proc.h> 36#include <sys/kernel.h> --- 319 unchanged lines hidden (view full) --- 356 */ 357int 358ntfs_ntget(ip) 359 struct ntnode *ip; 360{ 361 dprintf(("ntfs_ntget: get ntnode %d: %p, usecount: %d\n", 362 ip->i_number, ip, ip->i_usecount)); 363 | 29 */ 30 31#include <sys/param.h> 32#include <sys/types.h> 33#include <sys/systm.h> 34#include <sys/namei.h> 35#include <sys/proc.h> 36#include <sys/kernel.h> --- 319 unchanged lines hidden (view full) --- 356 */ 357int 358ntfs_ntget(ip) 359 struct ntnode *ip; 360{ 361 dprintf(("ntfs_ntget: get ntnode %d: %p, usecount: %d\n", 362 ip->i_number, ip, ip->i_usecount)); 363 |
364 simple_lock(&ip->i_interlock); | 364 mtx_enter(&ip->i_interlock, MTX_DEF); |
365 ip->i_usecount++; 366 LOCKMGR(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock); 367 368 return 0; 369} 370 371/* 372 * Routine search ntnode in hash, if found: lock, inc usecount and return. --- 32 unchanged lines hidden (view full) --- 405 ip->i_dev = ntmp->ntm_dev; 406 ip->i_number = ino; 407 ip->i_mp = ntmp; 408 409 LIST_INIT(&ip->i_fnlist); 410 411 /* init lock and lock the newborn ntnode */ 412 lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE); | 365 ip->i_usecount++; 366 LOCKMGR(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock); 367 368 return 0; 369} 370 371/* 372 * Routine search ntnode in hash, if found: lock, inc usecount and return. --- 32 unchanged lines hidden (view full) --- 405 ip->i_dev = ntmp->ntm_dev; 406 ip->i_number = ino; 407 ip->i_mp = ntmp; 408 409 LIST_INIT(&ip->i_fnlist); 410 411 /* init lock and lock the newborn ntnode */ 412 lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE); |
413 simple_lock_init(&ip->i_interlock); | 413 mtx_init(&ip->i_interlock, "ntnode interlock", MTX_DEF); |
414 ntfs_ntget(ip); 415 416 ntfs_nthashins(ip); 417 418 LOCKMGR(&ntfs_hashlock, LK_RELEASE, NULL); 419 420 *ipp = ip; 421 --- 13 unchanged lines hidden (view full) --- 435ntfs_ntput(ip) 436 struct ntnode *ip; 437{ 438 struct ntvattr *vap; 439 440 dprintf(("ntfs_ntput: rele ntnode %d: %p, usecount: %d\n", 441 ip->i_number, ip, ip->i_usecount)); 442 | 414 ntfs_ntget(ip); 415 416 ntfs_nthashins(ip); 417 418 LOCKMGR(&ntfs_hashlock, LK_RELEASE, NULL); 419 420 *ipp = ip; 421 --- 13 unchanged lines hidden (view full) --- 435ntfs_ntput(ip) 436 struct ntnode *ip; 437{ 438 struct ntvattr *vap; 439 440 dprintf(("ntfs_ntput: rele ntnode %d: %p, usecount: %d\n", 441 ip->i_number, ip, ip->i_usecount)); 442 |
443 simple_lock(&ip->i_interlock); | 443 mtx_enter(&ip->i_interlock, MTX_DEF); |
444 ip->i_usecount--; 445 446#ifdef DIAGNOSTIC 447 if (ip->i_usecount < 0) { 448 panic("ntfs_ntput: ino: %d usecount: %d \n", 449 ip->i_number,ip->i_usecount); 450 } 451#endif --- 7 unchanged lines hidden (view full) --- 459 460 ntfs_nthashrem(ip); 461 462 while (ip->i_valist.lh_first != NULL) { 463 vap = ip->i_valist.lh_first; 464 LIST_REMOVE(vap,va_list); 465 ntfs_freentvattr(vap); 466 } | 444 ip->i_usecount--; 445 446#ifdef DIAGNOSTIC 447 if (ip->i_usecount < 0) { 448 panic("ntfs_ntput: ino: %d usecount: %d \n", 449 ip->i_number,ip->i_usecount); 450 } 451#endif --- 7 unchanged lines hidden (view full) --- 459 460 ntfs_nthashrem(ip); 461 462 while (ip->i_valist.lh_first != NULL) { 463 vap = ip->i_valist.lh_first; 464 LIST_REMOVE(vap,va_list); 465 ntfs_freentvattr(vap); 466 } |
467 mtx_exit(&ip->i_interlock, MTX_DEF); 468 mtx_destroy(&ip->i_interlock); 469 lockdestroy(&ip->i_lock); 470 |
|
467 FREE(ip, M_NTFSNTNODE); 468 } else { 469 LOCKMGR(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); 470 } 471} 472 473/* 474 * increment usecount of ntnode 475 */ 476void 477ntfs_ntref(ip) 478 struct ntnode *ip; 479{ | 471 FREE(ip, M_NTFSNTNODE); 472 } else { 473 LOCKMGR(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); 474 } 475} 476 477/* 478 * increment usecount of ntnode 479 */ 480void 481ntfs_ntref(ip) 482 struct ntnode *ip; 483{ |
480 simple_lock(&ip->i_interlock); | 484 mtx_enter(&ip->i_interlock, MTX_DEF); |
481 ip->i_usecount++; | 485 ip->i_usecount++; |
482 simple_unlock(&ip->i_interlock); | 486 mtx_exit(&ip->i_interlock, MTX_DEF); |
483 484 dprintf(("ntfs_ntref: ino %d, usecount: %d\n", 485 ip->i_number, ip->i_usecount)); 486 487} 488 489/* 490 * Decrement usecount of ntnode. 491 */ 492void 493ntfs_ntrele(ip) 494 struct ntnode *ip; 495{ 496 dprintf(("ntfs_ntrele: rele ntnode %d: %p, usecount: %d\n", 497 ip->i_number, ip, ip->i_usecount)); 498 | 487 488 dprintf(("ntfs_ntref: ino %d, usecount: %d\n", 489 ip->i_number, ip->i_usecount)); 490 491} 492 493/* 494 * Decrement usecount of ntnode. 495 */ 496void 497ntfs_ntrele(ip) 498 struct ntnode *ip; 499{ 500 dprintf(("ntfs_ntrele: rele ntnode %d: %p, usecount: %d\n", 501 ip->i_number, ip, ip->i_usecount)); 502 |
499 simple_lock(&ip->i_interlock); | 503 mtx_enter(&ip->i_interlock, MTX_DEF); |
500 ip->i_usecount--; 501 502 if (ip->i_usecount < 0) 503 panic("ntfs_ntrele: ino: %d usecount: %d \n", 504 ip->i_number,ip->i_usecount); | 504 ip->i_usecount--; 505 506 if (ip->i_usecount < 0) 507 panic("ntfs_ntrele: ino: %d usecount: %d \n", 508 ip->i_number,ip->i_usecount); |
505 simple_unlock(&ip->i_interlock); | 509 mtx_exit(&ip->i_interlock, MTX_DEF); |
506} 507 508/* 509 * Deallocate all memory allocated for ntvattr 510 */ 511void 512ntfs_freentvattr(vap) 513 struct ntvattr * vap; --- 252 unchanged lines hidden (view full) --- 766 dprintf(("ntfs_frele: fnode: %p for %d: %p\n", fp, ip->i_number, ip)); 767 768 dprintf(("ntfs_frele: deallocating fnode\n")); 769 LIST_REMOVE(fp,f_fnlist); 770 if (fp->f_flag & FN_AATTRNAME) 771 FREE(fp->f_attrname, M_TEMP); 772 if (fp->f_dirblbuf) 773 FREE(fp->f_dirblbuf, M_NTFSDIR); | 510} 511 512/* 513 * Deallocate all memory allocated for ntvattr 514 */ 515void 516ntfs_freentvattr(vap) 517 struct ntvattr * vap; --- 252 unchanged lines hidden (view full) --- 770 dprintf(("ntfs_frele: fnode: %p for %d: %p\n", fp, ip->i_number, ip)); 771 772 dprintf(("ntfs_frele: deallocating fnode\n")); 773 LIST_REMOVE(fp,f_fnlist); 774 if (fp->f_flag & FN_AATTRNAME) 775 FREE(fp->f_attrname, M_TEMP); 776 if (fp->f_dirblbuf) 777 FREE(fp->f_dirblbuf, M_NTFSDIR); |
778#ifdef __FreeBSD__ 779 lockdestroy(&fp->f_lock); 780#endif |
|
774 FREE(fp, M_NTFSFNODE); 775 ntfs_ntrele(ip); 776} 777 778/* 779 * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME], 780 * $ATTR_TYPE is searched in attrdefs read from $AttrDefs. 781 * If $ATTR_TYPE nott specifed, ATTR_A_DATA assumed. --- 1128 unchanged lines hidden (view full) --- 1910void 1911ntfs_toupper_init() 1912{ 1913 ntfs_toupper_tab = (wchar *) NULL; 1914 lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0); 1915 ntfs_toupper_usecount = 0; 1916} 1917 | 781 FREE(fp, M_NTFSFNODE); 782 ntfs_ntrele(ip); 783} 784 785/* 786 * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME], 787 * $ATTR_TYPE is searched in attrdefs read from $AttrDefs. 788 * If $ATTR_TYPE nott specifed, ATTR_A_DATA assumed. --- 1128 unchanged lines hidden (view full) --- 1917void 1918ntfs_toupper_init() 1919{ 1920 ntfs_toupper_tab = (wchar *) NULL; 1921 lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0); 1922 ntfs_toupper_usecount = 0; 1923} 1924 |
1925void 1926ntfs_toupper_destroy(void) 1927{ 1928 1929 lockdestroy(&ntfs_toupper_lock); 1930} 1931 |
|
1918/* 1919 * if the ntfs_toupper_tab[] is filled already, just raise use count; 1920 * otherwise read the data from the filesystem we are currently mounting 1921 */ 1922int 1923ntfs_toupper_use(mp, ntmp) 1924 struct mount *mp; 1925 struct ntfsmount *ntmp; --- 71 unchanged lines hidden --- | 1932/* 1933 * if the ntfs_toupper_tab[] is filled already, just raise use count; 1934 * otherwise read the data from the filesystem we are currently mounting 1935 */ 1936int 1937ntfs_toupper_use(mp, ntmp) 1938 struct mount *mp; 1939 struct ntfsmount *ntmp; --- 71 unchanged lines hidden --- |