aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/Makefile
AgeCommit message (Expand)Author
2016-03-04usb: fsl: drop USB_FSL_MPH_DR_OF Kconfig symbolArnd Bergmann
2015-10-16usb-host: Remove fusbh200 driverPeter Senna Tschudin
2015-03-18usb: load usb phy earlierZhangfei Gao
2015-01-27usb: isp1760: Move driver from drivers/usb/host/ to drivers/usb/isp1760/Laurent Pinchart
2014-08-25usbip: move usbip kernel code out of stagingValentina Manea
2014-05-27usb: move usb/usb-common.c to usb/common/usb-common.cPeter Chen
2014-05-27Add support for using a MAX3421E chip as a host driver.David Mosberger
2014-01-13Move DWC2 driver out of stagingPaul Zimmerman
2013-08-13Merge tag 'usb-for-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/ba...Greg Kroah-Hartman
2013-07-29usb: host: Faraday fotg210-hcd driverFeng-Hsin Chiang
2013-07-29usb: phy: make PHY driver selection possible by controller driversRoger Quadros
2013-07-24Revert "usb: host: Faraday fotg210-hcd driver"Greg Kroah-Hartman
2013-07-24usb: host: Faraday fotg210-hcd driverYuan-Hsin Chen
2013-05-17usb host: Faraday USB2.0 FUSBH200-HCD driverYuan-Hsin Chen
2013-03-18usb: phy: remove CONFIG_USB_OTG_UTILSFelipe Balbi
2013-03-18usb: phy: move all PHY drivers to drivers/usb/phy/Felipe Balbi
2013-03-07usb: Makefile: fix drivers/usb/phy/ Makefile entryFelipe Balbi
2012-06-26usb: phy: Fix Kconfig dependency for Phy driversAlexandre Pereira da Silva
2012-05-11usb: move ci13xxx and related code to drivers/usb/chipideaAlexander Shishkin
2012-05-01USB: Add driver for NXP ISP1301 USB transceiverRoland Stigge
2011-11-26USB: OTG should be linked before HostNeil Zhang
2011-09-18usb: Provide usb_speed_string() functionMichal Nazarewicz
2011-08-22usb: Introduce DesignWare USB3 DRD DriverFelipe Balbi
2011-05-02USB: fix build of FSL MPH DR OF platform driverAnatolij Gustschin
2011-04-13usb: don't enter usb subdirectories directlyFelipe Balbi
2010-08-10USB: drivers/usb/Makefile: conditionally descend to 'early'Nicolas Kaiser
2010-03-02USB: MXC: Add i.MX21 specific USB host controller driver.Martin Fuzzey
2009-12-23USB: Fix double-linking of drivers/usb/otg when ULPI is selectedBill Gatliff
2009-12-11USB OTG: Add generic driver for ULPI OTG transceiverDaniel Mack
2009-09-23USB: ehci,dbgp,early_printk: split ehci debug driver from early_printk.cJason Wessel
2009-09-23USB: NXP ISP1362 USB host driverLothar Wassmann
2009-06-15USB: xhci: Add Makefile, MAINTAINERS, and Kconfig entries.Sarah Sharp
2009-05-28Revert "USB: Correct Makefile to make isp1760 buildable"Mike Frysinger
2009-05-08USB: Fix makefile so that CONFIG_WDM and CONFIG_TMC work.Andy Lutomirski
2009-03-24USB: Add platform device support for the ISP1760 USB chipCatalin Marinas
2009-02-09USB: Correct Makefile to make isp1760 buildableIvan Kuten
2009-01-27USB: Driver for Freescale QUICC Engine USB Host ControllerAnton Vorontsov
2008-09-17wusb: add HWA host controller driverInaky Perez-Gonzalez
2008-09-17wusb: add the Wireless USB core (build-system)Greg Kroah-Hartman
2008-05-02USB: add Cypress c67x00 OTG controller HCD driverPeter Korsgaard
2007-10-12USB: always visit drivers/usb/misc/Adrian Bunk
2007-10-12USB: Add drivers/usb/misc/iowarrior.c to the MakefileNico Erfurth
2007-07-30USB: devices misc: Trivial patch to build the IOWARRIOR when it is selected i...Juergen Beisert
2007-07-12USB: remove Makefile reference to obsolete OHCI_AT91Robert P. J. Day
2007-07-12USB: r8a66597-hcd: host controller driver for R8A66597Yoshihiro Shimoda
2007-05-09Move USB network drivers to drivers/net/usb.Jeff Garzik
2007-05-08Input: move USB miscellaneous devices under drivers/input/miscDmitry Torokhov
2007-05-08Input: move USB gamepads under drivers/input/joystickDmitry Torokhov
2007-05-08Input: move USB touchscreens under drivers/input/touchscreenDmitry Torokhov
2007-05-08Input: move USB tablets under drivers/input/tabletDmitry Torokhov
andard/base'>v5.8/standard/base Yocto Linux Embedded kernelGrokmirror user
aboutsummaryrefslogtreecommitdiffstats
path: root/fs/utimes.c
blob: 69d4b6ba1bfb685489e27f06b21d94c95aa7f2a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// SPDX-License-Identifier: GPL-2.0
#include <linux/file.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/utime.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
#include <linux/compat.h>
#include <asm/unistd.h>

#ifdef __ARCH_WANT_SYS_UTIME

/*
 * sys_utime() can be implemented in user-level using sys_utimes().
 * Is this for backwards compatibility?  If so, why not move it
 * into the appropriate arch directory (for those architectures that
 * need it).
 */

/* If times==NULL, set access and modification to current time,
 * must be owner or have write permission.
 * Else, update from *times, must be owner or super user.
 */
SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times)
{
	struct timespec64 tv[2];

	if (times) {
		if (get_user(tv[0].tv_sec, &times->actime) ||
		    get_user(tv[1].tv_sec, &times->modtime))
			return -EFAULT;
		tv[0].tv_nsec = 0;
		tv[1].tv_nsec = 0;
	}
	return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0);
}

#endif

static bool nsec_valid(long nsec)
{
	if (nsec == UTIME_OMIT || nsec == UTIME_NOW)
		return true;

	return nsec >= 0 && nsec <= 999999999;
}

static int utimes_common(const struct path *path, struct timespec64 *times)
{
	int error;
	struct iattr newattrs;
	struct inode *inode = path->dentry->d_inode;
	struct inode *delegated_inode = NULL;

	error = mnt_want_write(path->mnt);
	if (error)
		goto out;

	if (times && times[0].tv_nsec == UTIME_NOW &&
		     times[1].tv_nsec == UTIME_NOW)
		times = NULL;

	newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
	if (times) {
		if (times[0].tv_nsec == UTIME_OMIT)
			newattrs.ia_valid &= ~ATTR_ATIME;
		else if (times[0].tv_nsec != UTIME_NOW) {
			newattrs.ia_atime.tv_sec = times[0].tv_sec;
			newattrs.ia_atime.tv_nsec = times[0].tv_nsec;
			newattrs.ia_valid |= ATTR_ATIME_SET;
		}

		if (times[1].tv_nsec == UTIME_OMIT)
			newattrs.ia_valid &= ~ATTR_MTIME;
		else if (times[1].tv_nsec != UTIME_NOW) {
			newattrs.ia_mtime.tv_sec = times[1].tv_sec;
			newattrs.ia_mtime.tv_nsec = times[1].tv_nsec;
			newattrs.ia_valid |= ATTR_MTIME_SET;
		}
		/*
		 * Tell setattr_prepare(), that this is an explicit time
		 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
		 * were used.
		 */
		newattrs.ia_valid |= ATTR_TIMES_SET;
	} else {
		newattrs.ia_valid |= ATTR_TOUCH;
	}
retry_deleg:
	inode_lock(inode);
	error = notify_change(path->dentry, &newattrs, &delegated_inode);
	inode_unlock(inode);
	if (delegated_inode) {
		error = break_deleg_wait(&delegated_inode);
		if (!error)
			goto retry_deleg;
	}

	mnt_drop_write(path->mnt);
out:
	return error;
}

/*
 * do_utimes - change times on filename or file descriptor
 * @dfd: open file descriptor, -1 or AT_FDCWD
 * @filename: path name or NULL
 * @times: new times or NULL
 * @flags: zero or more flags (only AT_SYMLINK_NOFOLLOW for the moment)
 *
 * If filename is NULL and dfd refers to an open file, then operate on
 * the file.  Otherwise look up filename, possibly using dfd as a
 * starting point.
 *
 * If times==NULL, set access and modification to current time,
 * must be owner or have write permission.
 * Else, update from *times, must be owner or super user.
 */
long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
	       int flags)
{
	int error = -EINVAL;

	if (times && (!nsec_valid(times[0].tv_nsec) ||
		      !nsec_valid(times[1].tv_nsec))) {
		goto out;
	}

	if (flags & ~AT_SYMLINK_NOFOLLOW)
		goto out;

	if (filename == NULL && dfd != AT_FDCWD) {
		struct fd f;

		if (flags & AT_SYMLINK_NOFOLLOW)
			goto out;

		f = fdget(dfd);
		error = -EBADF;
		if (!f.file)
			goto out;

		error = utimes_common(&f.file->f_path, times);
		fdput(f);
	} else {
		struct path path;
		int lookup_flags = 0;

		if (!(flags & AT_SYMLINK_NOFOLLOW))
			lookup_flags |= LOOKUP_FOLLOW;
retry:
		error = user_path_at(dfd, filename, lookup_flags, &path);
		if (error)
			goto out;

		error = utimes_common(&path, times);
		path_put(&path);
		if (retry_estale(error, lookup_flags)) {
			lookup_flags |= LOOKUP_REVAL;
			goto retry;
		}
	}

out:
	return error;
}

SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename,
		struct timespec __user *, utimes, int, flags)
{
	struct timespec64 tstimes[2];

	if (utimes) {
		if ((get_timespec64(&tstimes[0], &utimes[0]) ||
			get_timespec64(&tstimes[1], &utimes[1])))
			return -EFAULT;

		/* Nothing to do, we must not even check the path.  */
		if (tstimes[0].tv_nsec == UTIME_OMIT &&
		    tstimes[1].tv_nsec == UTIME_OMIT)
			return 0;
	}

	return do_utimes(dfd, filename, utimes ? tstimes : NULL, flags);
}

static long do_futimesat(int dfd, const char __user *filename,
			 struct timeval __user *utimes)
{
	struct timeval times[2];
	struct timespec64 tstimes[2];

	if (utimes) {
		if (copy_from_user(&times, utimes, sizeof(times)))
			return -EFAULT;

		/* This test is needed to catch all invalid values.  If we
		   would test only in do_utimes we would miss those invalid
		   values truncated by the multiplication with 1000.  Note
		   that we also catch UTIME_{NOW,OMIT} here which are only
		   valid for utimensat.  */
		if (times[0].tv_usec >= 1000000 || times[0].tv_usec < 0 ||
		    times[1].tv_usec >= 1000000 || times[1].tv_usec < 0)
			return -EINVAL;

		tstimes[0].tv_sec = times[0].tv_sec;
		tstimes[0].tv_nsec = 1000 * times[0].tv_usec;
		tstimes[1].tv_sec = times[1].tv_sec;
		tstimes[1].tv_nsec = 1000 * times[1].tv_usec;
	}

	return do_utimes(dfd, filename, utimes ? tstimes : NULL, 0);
}


SYSCALL_DEFINE3(futimesat, int, dfd, const char __user *, filename,
		struct timeval __user *, utimes)
{
	return do_futimesat(dfd, filename, utimes);
}

SYSCALL_DEFINE2(utimes, char __user *, filename,
		struct timeval __user *, utimes)
{
	return do_futimesat(AT_FDCWD, filename, utimes);
}

#ifdef CONFIG_COMPAT
/*
 * Not all architectures have sys_utime, so implement this in terms
 * of sys_utimes.
 */
COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
		       struct compat_utimbuf __user *, t)
{
	struct timespec64 tv[2];

	if (t) {
		if (get_user(tv[0].tv_sec, &t->actime) ||
		    get_user(tv[1].tv_sec, &t->modtime))
			return -EFAULT;
		tv[0].tv_nsec = 0;
		tv[1].tv_nsec = 0;
	}
	return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
}

COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags)
{
	struct timespec64 tv[2];

	if  (t) {
		if (compat_get_timespec64(&tv[0], &t[0]) ||
		    compat_get_timespec64(&tv[1], &t[1]))
			return -EFAULT;

		if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
			return 0;
	}
	return do_utimes(dfd, filename, t ? tv : NULL, flags);
}

static long do_compat_futimesat(unsigned int dfd, const char __user *filename,
				struct compat_timeval __user *t)
{
	struct timespec64 tv[2];

	if (t) {
		if (get_user(tv[0].tv_sec, &t[0].tv_sec) ||
		    get_user(tv[0].tv_nsec, &t[0].tv_usec) ||
		    get_user(tv[1].tv_sec, &t[1].tv_sec) ||
		    get_user(tv[1].tv_nsec, &t[1].tv_usec))
			return -EFAULT;
		if (tv[0].tv_nsec >= 1000000 || tv[0].tv_nsec < 0 ||
		    tv[1].tv_nsec >= 1000000 || tv[1].tv_nsec < 0)
			return -EINVAL;
		tv[0].tv_nsec *= 1000;
		tv[1].tv_nsec *= 1000;
	}
	return do_utimes(dfd, filename, t ? tv : NULL, 0);
}

COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd,
		       const char __user *, filename,
		       struct compat_timeval __user *, t)
{
	return do_compat_futimesat(dfd, filename, t);
}

COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t)
{
	return do_compat_futimesat(AT_FDCWD, filename, t);
}
#endif