summaryrefslogtreecommitdiffstats
path: root/sys/fs/smbfs/smbfs_vnops.c
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup unnecessary semicolons from the kernel.pfg2016-04-101-1/+1
| | | | Found with devel/coccinelle.
* Change the type of newsize argument in the smbfs_smb_setfsize() functionae2016-01-111-1/+2
| | | | | | | | | | | | | | from int to int64. MSDN says that SMB_SET_FILE_END_OF_FILE_INFO uses signed 64-bit integer to specify offset, but since smbfs_smb_setfsize() has used plain int, a value was truncated in case when offset was larger than 2G. https://msdn.microsoft.com/en-us/library/ff469975.aspx In particular, now `truncate -s 10G` will work correctly on the mounted SMB share. Reported and tested by: Eugene Grosbein <eugen at grosbein dot net> MFC after: 1 week
* Expand the use of stat(2) flags to allow storing some Windows/DOSken2013-08-211-8/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and CIFS file attributes as BSD stat(2) flags. This work is intended to be compatible with ZFS, the Solaris CIFS server's interaction with ZFS, somewhat compatible with MacOS X, and of course compatible with Windows. The Windows attributes that are implemented were chosen based on the attributes that ZFS already supports. The summary of the flags is as follows: UF_SYSTEM: Command line name: "system" or "usystem" ZFS name: XAT_SYSTEM, ZFS_SYSTEM Windows: FILE_ATTRIBUTE_SYSTEM This flag means that the file is used by the operating system. FreeBSD does not enforce any special handling when this flag is set. UF_SPARSE: Command line name: "sparse" or "usparse" ZFS name: XAT_SPARSE, ZFS_SPARSE Windows: FILE_ATTRIBUTE_SPARSE_FILE This flag means that the file is sparse. Although ZFS may modify this in some situations, there is not generally any special handling for this flag. UF_OFFLINE: Command line name: "offline" or "uoffline" ZFS name: XAT_OFFLINE, ZFS_OFFLINE Windows: FILE_ATTRIBUTE_OFFLINE This flag means that the file has been moved to offline storage. FreeBSD does not have any special handling for this flag. UF_REPARSE: Command line name: "reparse" or "ureparse" ZFS name: XAT_REPARSE, ZFS_REPARSE Windows: FILE_ATTRIBUTE_REPARSE_POINT This flag means that the file is a Windows reparse point. ZFS has special handling code for reparse points, but we don't currently have the other supporting infrastructure for them. UF_HIDDEN: Command line name: "hidden" or "uhidden" ZFS name: XAT_HIDDEN, ZFS_HIDDEN Windows: FILE_ATTRIBUTE_HIDDEN This flag means that the file may be excluded from a directory listing if the application honors it. FreeBSD has no special handling for this flag. The name and bit definition for UF_HIDDEN are identical to the definition in MacOS X. UF_READONLY: Command line name: "urdonly", "rdonly", "readonly" ZFS name: XAT_READONLY, ZFS_READONLY Windows: FILE_ATTRIBUTE_READONLY This flag means that the file may not written or appended, but its attributes may be changed. ZFS currently enforces this flag, but Illumos developers have discussed disabling enforcement. The behavior of this flag is different than MacOS X. MacOS X uses UF_IMMUTABLE to represent the DOS readonly permission, but that flag has a stronger meaning than the semantics of DOS readonly permissions. UF_ARCHIVE: Command line name: "uarch", "uarchive" ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE Windows name: FILE_ATTRIBUTE_ARCHIVE The UF_ARCHIVED flag means that the file has changed and needs to be archived. The meaning is same as the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute. msdosfs and ZFS have special handling for this flag. i.e. they will set it when the file changes. sys/param.h: Bump __FreeBSD_version to 1000047 for the addition of new stat(2) flags. chflags.1: Document the new command line flag names (e.g. "system", "hidden") available to the user. ls.1: Reference chflags(1) for a list of file flags and their meanings. strtofflags.c: Implement the mapping between the new command line flag names and new stat(2) flags. chflags.2: Document all of the new stat(2) flags, and explain the intended behavior in a little more detail. Explain how they map to Windows file attributes. Different filesystems behave differently with respect to flags, so warn the application developer to take care when using them. zfs_vnops.c: Add support for getting and setting the UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN, UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags. All of these flags are implemented using attributes that ZFS already supports, so the on-disk format has not changed. ZFS currently doesn't allow setting the UF_REPARSE flag, and we don't really have the other infrastructure to support reparse points. msdosfs_denode.c, msdosfs_vnops.c: Add support for getting and setting UF_HIDDEN, UF_SYSTEM and UF_READONLY in MSDOSFS. It supported SF_ARCHIVED, but this has been changed to be UF_ARCHIVE, which has the same semantics as the DOS archive attribute instead of inverse semantics like SF_ARCHIVED. After discussion with Bruce Evans, change several things in the msdosfs behavior: Use UF_READONLY to indicate whether a file is writeable instead of file permissions, but don't actually enforce it. Refuse to change attributes on the root directory, because it is special in FAT filesystems, but allow most other attribute changes on directories. Don't set the archive attribute on a directory when its modification time is updated. Windows and DOS don't set the archive attribute in that scenario, so we are now bug-for-bug compatible. smbfs_node.c, smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM, UF_READONLY and UF_ARCHIVE in SMBFS. This is similar to changes that Apple has made in their version of SMBFS (as of smb-583.8, posted on opensource.apple.com), but not quite the same. We map SMB_FA_READONLY to UF_READONLY, because UF_READONLY is intended to match the semantics of the DOS readonly flag. The MacOS X code maps both UF_IMMUTABLE and SF_IMMUTABLE to SMB_FA_READONLY, but the immutable flags have stronger meaning than the DOS readonly bit. stat.h: Add definitions for UF_SYSTEM, UF_SPARSE, UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY and UF_HIDDEN. The definition of UF_HIDDEN is the same as the MacOS X definition. Add commented-out definitions of UF_COMPRESSED and UF_TRACKED. They are defined in MacOS X (as of 10.8.2), but we do not implement them (yet). ufs_vnops.c: Add support for getting and setting UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY, UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS. Alphabetize the flags that are supported. These new flags are only stored, UFS does not take any action if the flag is set. Sponsored by: Spectra Logic Reviewed by: bde (earlier version)
* Plug a couple of leakages in smbfs_lookup().davide2013-06-281-3/+6
|
* smbfs_lookup() in the DOTDOT case operates on dvp->n_parent withoutdavide2013-03-091-6/+13
| | | | | | | | | | proper locking. This doesn't prevent in any case reclaim of the vnode. Avoid this not going over-the-wire in this case and relying on subsequent smbfs_getattr() call to restore consistency. While I'm here, change a couple of SMBVDEBUG() in MPASS(). sbmfs_smb_lookup() doesn't and shouldn't know about '.' and '..' Reported by: pho's stress2 suite
* - Initialize variable in smbfs_rename() to silent compiler warningdavide2013-03-091-1/+2
| | | | | | - Fix smbfs_mkdir() return value (in case of error). Reported by: pho
* - smbfs_rename() might return an error value without correctly upgradingdavide2012-11-261-2/+2
| | | | | | | | the vnode use count, and this might cause the kernel to panic if compiled with WITNESS enable. - Be sure to put the '\0' terminator to the rpath string. Sponsored by: iXsystems inc.
* Get rid of some old debug code. It provides checks similar to the onedavide2012-11-141-12/+0
| | | | | | offered by RedZone so there's no need to keep it. Sponsored by: iXsystems inc.
* Fix the lookup in the DOTDOT case in the same way as other filesystems do,davide2012-11-141-0/+21
| | | | | | i.e. inlining the vn_vget_ino() algorithm. Sponsored by: iXsystems inc.
* Fix panic due to page faults while in kernel mode, under conditions ofdavide2012-10-311-82/+118
| | | | | | | | | VM pressure. The reason is that in some codepaths pointers to stack variables were passed from one thread to another. In collaboration with: pho Reported by: pho's stress2 suite Sponsored by: iXsystems inc.
* Change the code to use %jd as printf() placeholder for uio_offset anddavide2012-10-311-1/+1
| | | | | | | cast to intmax_t. Suggested by: pjd Sponsored by: iXsystems inc.
* Fix build in case we have SMBVDEBUG turned on.davide2012-10-251-1/+2
| | | | | | Reviewed by: gnn Approved by: gnn Sponsored by: iXsystems inc.
* Rename cache_lookup_times() to cache_lookup() and retire the old API andjhb2012-02-061-1/+1
| | | | ABI stub for cache_lookup().
* Use strchr() and strrchr().ed2012-01-021-5/+5
| | | | | | | | It seems strchr() and strrchr() are used more often than index() and rindex(). Therefore, simply migrate all kernel code to use it. For the XFS code, remove an empty line to make the code identical to the code in the Linux kernel.
* Switch to our preferred 2-clause BSD license.joel2010-04-071-6/+0
| | | | Approved by: bp
* After r186194 the *fs_strategy() functions always return 0.bz2009-01-311-2/+1
| | | | | | | | So we are no longer interested in the error returned from the *fs_doio() functions. With that we can remove the error variable as its value is unused now. Submitted by: Christoph Mallon christoph.mallon@gmx.de
* According to phk@, VOP_STRATEGY should never, _ever_, returntrasz2008-12-161-1/+1
| | | | | | | | | | | | | anything other than 0. Make it so. This fixes "panic: VOP_STRATEGY failed bp=0xc320dd90 vp=0xc3b9f648", encountered when writing to an orphaned filesystem. Reason for the panic was the following assert: KASSERT(i == 0, ("VOP_STRATEGY failed bp=%p vp=%p", bp, bp->b_vp)); at vfs_bio:bufstrategy(). Reviewed by: scottl, phk Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Introduce accmode_t. This is required for NFSv4 ACLs - it will be neccessarytrasz2008-10-281-4/+4
| | | | | | | to add more V* constants, and the variables changed by this patch were often being assigned to mode_t variables, which is 16 bit. Approved by: rwatson (mentor)
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadattilio2008-08-281-21/+21
| | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
* Move the head of byte-level advisory lock list from thekib2008-04-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | filesystem-specific vnode data to the struct vnode. Provide the default implementation for the vop_advlock and vop_advlockasync. Purge the locks on the vnode reclaim by using the lf_purgelocks(). The default implementation is augmented for the nfs and smbfs. In the nfs_advlock, push the Giant inside the nfs_dolock. Before the change, the vop_advlock and vop_advlockasync have taken the unlocked vnode and dereferenced the fs-private inode data, racing with with the vnode reclamation due to forced unmount. Now, the vop_getattr under the shared vnode lock is used to obtain the inode size, and later, in the lf_advlockasync, after locking the vnode interlock, the VI_DOOMED flag is checked to prevent an operation on the doomed vnode. The implementation of the lf_purgelocks() is submitted by dfr. Reported by: kris Tested by: kris, pho Discussed with: jeff, dfr MFC after: 2 weeks
* When calling lf_advlock to unlock a record, make sure that ap->a_fl->l_typedfr2008-04-141-0/+3
| | | | | | is F_UNLCK otherwise we trigger a LOCKF_DEBUG panic. MFC after: 3 days
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-1/+1
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-101-1/+1
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-1/+1
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-5/+7
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* Create a bidirectional mapping of the DOS 'read only' attributebp2006-11-051-0/+14
| | | | | | | | to the 'w' flag. PR: kern/77958 Submitted by: ghozzy gmail com MFC after: 1 month
* Enable inadvertantly disabled "securenet" access controls in ypserv. [1]cperciva2006-05-311-1/+8
| | | | | | | | Correct a bug in the handling of backslash characters in smbfs which can allow an attacker to escape from a chroot(2). [2] Security: FreeBSD-SA-06:15.ypserv [1] Security: FreeBSD-SA-06:16.smbfs [2]
* - Change all filesystems and vfs_cache to relock the dvp once the child isjeff2005-04-131-6/+2
| | | | | | locked in the ISDOTDOT case. Se vfs_lookup.c r1.79 for details. Sponsored by: Isilon Systems, Inc.
* Initialize vp before using it. Failing to do this can cause instantdelphij2005-04-101-0/+1
| | | | | | panic when trying to access a file on mounted smbfs. Submitted by: takawata at jp freebsd org
* - Remove wantparent, it is no longer necessary. An assert in vfs_lookup.cjeff2005-03-291-4/+3
| | | | | prevents any callers from doing a modifying op without LOCKPARENT or WANTPARENT.
* - cache_lookup() now locks the new vnode for us to prevent some races.jeff2005-03-291-57/+37
| | | | | | Remove redundant code. Sponsored by: Isilon Systems, Inc.
* - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.jeff2005-03-281-54/+21
| | | | | | | | | | | - Network filesystems are written with a special idiom that checks the cache first, and may even unlock dvp before discovering that a network round-trip is required to resolve the name. I believe dvp is prevented from being recycled even in the forced unmount case by the shared lock on the mount point. If not, this code should grow checks for VI_DOOMED after it relocks dvp or it will access NULL v_data fields. Sponsored by: Isilon Systems, Inc.
* - The VI_DOOMED flag now signals the end of a vnode's relationship withjeff2005-03-131-14/+1
| | | | | | | | the filesystem. Check that rather than VI_XLOCK. - VOP_INACTIVE should no longer drop the vnode lock. - The vnode lock is required around calls to vrecycle() and vgone(). Sponsored by: Isilon Systems, Inc.
* vp->v_id is a private field for the vfs namecache and it is a big mistakephk2005-02-221-25/+24
| | | | | | | that NFS ever started using it and an even bigger that it got copied&pasted to nwfs and smbfs. Replace with use of vhold()/vdrop().
* Unbreak a few filesystems for which vnode_create_vobject() wasn't beingpeadar2005-01-291-1/+3
| | | | | | | | | called in "open", causing mmap() to fail. Where possible, pass size of file to vnode_create_vobject() rather than having it find it out the hard way via VOP_LOOKUP Reviewed by: phk
* Eliminate unused and constant arguments to smbfs_vinvalbuf()phk2005-01-141-2/+2
|
* Whitespace in vop_vector{} initializations.phk2005-01-131-2/+3
|
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Convert to nmount. Add omount compat.phk2004-12-061-5/+4
| | | | Unpropagate the sm_args function into the runtime part.
* Back when VOP_* was introduced, we did not have new-style structphk2004-12-011-38/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initializations but we did have lofty goals and big ideals. Adjust to more contemporary circumstances and gain type checking. Replace the entire vop_t frobbing thing with properly typed structures. The only casualty is that we can not add a new VOP_ method with a loadable module. History has not given us reason to belive this would ever be feasible in the the first place. Eliminate in toto VOCALL(), vop_t, VNODEOP_SET() etc. Give coda correct prototypes and function definitions for all vop_()s. Generate a bit more data from the vnode_if.src file: a struct vop_vector and protype typedefs for all vop methods. Add a new vop_bypass() and make vop_default be a pointer to another struct vop_vector. Remove a lot of vfs_init since vop_vector is ready to use from the compiler. Cast various vop_mumble() to void * with uppercase name, for instance VOP_PANIC, VOP_NULL etc. Implement VCALL() by making vdesc_offset the offsetof() the relevant function pointer in vop_vector. This is disgusting but since the code is generated by a script comparatively safe. The alternative for nullfs etc. would be much worse. Fix up all vnode method vectors to remove casts so they become typesafe. (The bulk of this is generated by scripts)
* Mechanically change prototypes for vnode operations to use the new typedefs.phk2004-12-011-23/+23
|
* Explicitly pass vnode to smbfs_doio() function.phk2004-09-071-3/+1
|
* Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL. This iscperciva2004-07-261-1/+1
| | | | | | | | | | | somewhat clearer, but more importantly allows for a consistent naming scheme for suser_cred flags. The old name is still defined, but will be removed in a few days (unless I hear any complaints...) Discussed with: rwatson, scottl Requested by: jhb
* Fixes problems that occurred when a file was removed and a directorytjr2004-02-101-1/+24
| | | | | | | | | | | | | | | | created with the same name, and vice versa: - Immediately recycle vnodes of files & directories that have been deleted or renamed. - When looking an entry in the VFS name cache or smbfs's private cache, make sure the vnode type is consistent with the type of file the server thinks it is, and re-create the vnode if it isn't. The alternative to this is to recycle vnodes unconditionally when their use count drops to 0, but this would make all the caching we do mostly useless. PR: 62342 MFC after: 2 weeks
* Restore closing of SMB find handle in smbfs_close().tjr2004-01-101-1/+8
|
* Make oldsize in smbfs_getattr() 64 bits wide instead of 32 to avoidtjr2003-12-221-1/+1
| | | | truncation when files are larger than 4GB.
* Initialize b_offset before calling VOP_STRATEGY/VOP_SPECSTRATEGY.phk2003-10-181-1/+0
| | | | | Remove various comments of KASSERTS and comments about B_PHYS which does not apply anymore.
* Convert some if(bla) panic("foo") to KASSERTS to improve grep-ability.phk2003-10-181-2/+1
|
* Allow the [, ], and = characters in non-8.3 filenames since theytjr2003-09-261-2/+2
| | | | | | | | | | | are allowed by Windows (ref: MS KB article 120138). XXX From my reading of the CIFS specification, it's not clear that clients need to validate filenames at all. PR: 57123 Submitted by: Paul Coucher MFC after: 1 month
* Add a "int fd" argument to VOP_OPEN() which in the future willphk2003-07-261-1/+1
| | | | | | | | | contain the filedescriptor number on opens from userland. The index is used rather than a "struct file *" since it conveys a bit more information, which may be useful to in particular fdescfs and /dev/fd/* For now pass -1 all over the place.
OpenPOWER on IntegriCloud