summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2013-03-21 22:44:33 +0000
committerpjd <pjd@FreeBSD.org>2013-03-21 22:44:33 +0000
commit2a3cf7f364f936c42d03f20e3517e2213372b6bd (patch)
tree1c36abb6f394391f7fb768b78ab2d383820e11cb
parentc966fdfb31aaad19afdaeaa7727b7f658662f433 (diff)
downloadFreeBSD-src-2a3cf7f364f936c42d03f20e3517e2213372b6bd.zip
FreeBSD-src-2a3cf7f364f936c42d03f20e3517e2213372b6bd.tar.gz
- Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type
u_long. Before this change it was of type int for syscalls, but prototypes in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not for lchflags(2)) stated that it was u_long. Now some related functions use u_long type for flags (strtofflags(3), fflagstostr(3)). - Make path argument of type 'const char *' for consistency. Discussed on: arch Sponsored by: The FreeBSD Foundation
-rw-r--r--bin/chflags/chflags.c6
-rw-r--r--bin/mv/mv.c2
-rw-r--r--lib/libc/sys/chflags.26
-rw-r--r--sys/compat/freebsd32/syscalls.master7
-rw-r--r--sys/fs/tmpfs/tmpfs.h4
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c3
-rw-r--r--sys/kern/syscalls.master7
-rw-r--r--sys/kern/vfs_syscalls.c20
-rw-r--r--sys/sys/stat.h2
-rw-r--r--tools/regression/pjdfstest/pjdfstest.c3
10 files changed, 30 insertions, 30 deletions
diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c
index 2c07db9..e94c34d 100644
--- a/bin/chflags/chflags.c
+++ b/bin/chflags/chflags.c
@@ -117,11 +117,7 @@ main(int argc, char *argv[])
} else
fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
- /* XXX: Why don't chflags and lchflags have compatible prototypes? */
- if (hflag)
- change_flags = (int (*)(const char *, unsigned long))lchflags;
- else
- change_flags = chflags;
+ change_flags = hflag ? lchflags : chflags;
flags = *argv;
if (*flags >= '0' && *flags <= '7') {
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 5147a2db..2710f89 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -337,7 +337,7 @@ err: if (unlink(to))
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
- if (fchflags(to_fd, (u_long)sbp->st_flags))
+ if (fchflags(to_fd, sbp->st_flags))
if (errno != EOPNOTSUPP || sbp->st_flags != 0)
warn("%s: set flags (was: 0%07o)", to, sbp->st_flags);
diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2
index ab8af51..51c3cf7 100644
--- a/lib/libc/sys/chflags.2
+++ b/lib/libc/sys/chflags.2
@@ -42,11 +42,11 @@
.In sys/stat.h
.In unistd.h
.Ft int
-.Fn chflags "const char *path" "u_long flags"
+.Fn chflags "const char *path" "unsigned long flags"
.Ft int
-.Fn lchflags "const char *path" "int flags"
+.Fn lchflags "const char *path" "unsigned long flags"
.Ft int
-.Fn fchflags "int fd" "u_long flags"
+.Fn fchflags "int fd" "unsigned long flags"
.Sh DESCRIPTION
The file whose name
is given by
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master
index 655296c..e7a18aa 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
@@ -114,8 +114,8 @@
32 AUE_GETSOCKNAME NOPROTO { int getsockname(int fdes, caddr_t asa, \
int *alen); }
33 AUE_ACCESS NOPROTO { int access(char *path, int amode); }
-34 AUE_CHFLAGS NOPROTO { int chflags(char *path, int flags); }
-35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); }
+34 AUE_CHFLAGS NOPROTO { int chflags(const char *path, u_long flags); }
+35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, u_long flags); }
36 AUE_SYNC NOPROTO { int sync(void); }
37 AUE_KILL NOPROTO { int kill(int pid, int signum); }
38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \
@@ -693,7 +693,8 @@
389 AUE_NULL UNIMPL __mac_set_file
390 AUE_NULL NOPROTO { int kenv(int what, const char *name, \
char *value, int len); }
-391 AUE_LCHFLAGS NOPROTO { int lchflags(const char *path, int flags); }
+391 AUE_LCHFLAGS NOPROTO { int lchflags(const char *path, \
+ u_long flags); }
392 AUE_NULL NOPROTO { int uuidgen(struct uuid *store, \
int count); }
393 AUE_SENDFILE STD { int freebsd32_sendfile(int fd, int s, \
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h
index 8073c64..8f03f10 100644
--- a/sys/fs/tmpfs/tmpfs.h
+++ b/sys/fs/tmpfs/tmpfs.h
@@ -183,7 +183,7 @@ struct tmpfs_node {
uid_t tn_uid;
gid_t tn_gid;
mode_t tn_mode;
- int tn_flags;
+ u_long tn_flags;
nlink_t tn_links;
struct timespec tn_atime;
struct timespec tn_mtime;
@@ -418,7 +418,7 @@ int tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, int,
int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *);
void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *);
int tmpfs_reg_resize(struct vnode *, off_t, boolean_t);
-int tmpfs_chflags(struct vnode *, int, struct ucred *, struct thread *);
+int tmpfs_chflags(struct vnode *, u_long, struct ucred *, struct thread *);
int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,
struct thread *);
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index b003b2c..4739f85 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1355,7 +1355,8 @@ retry:
* The vnode must be locked on entry and remain locked on exit.
*/
int
-tmpfs_chflags(struct vnode *vp, int flags, struct ucred *cred, struct thread *p)
+tmpfs_chflags(struct vnode *vp, u_long flags, struct ucred *cred,
+ struct thread *p)
{
int error;
struct tmpfs_node *node;
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 9c22f2b..7b45c80 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -115,8 +115,8 @@
struct sockaddr * __restrict asa, \
__socklen_t * __restrict alen); }
33 AUE_ACCESS STD { int access(char *path, int amode); }
-34 AUE_CHFLAGS STD { int chflags(char *path, int flags); }
-35 AUE_FCHFLAGS STD { int fchflags(int fd, int flags); }
+34 AUE_CHFLAGS STD { int chflags(const char *path, u_long flags); }
+35 AUE_FCHFLAGS STD { int fchflags(int fd, u_long flags); }
36 AUE_SYNC STD { int sync(void); }
37 AUE_KILL STD { int kill(int pid, int signum); }
38 AUE_STAT COMPAT { int stat(char *path, struct ostat *ub); }
@@ -696,7 +696,8 @@
struct mac *mac_p); }
390 AUE_NULL STD { int kenv(int what, const char *name, \
char *value, int len); }
-391 AUE_LCHFLAGS STD { int lchflags(const char *path, int flags); }
+391 AUE_LCHFLAGS STD { int lchflags(const char *path, \
+ u_long flags); }
392 AUE_NULL STD { int uuidgen(struct uuid *store, \
int count); }
393 AUE_SENDFILE STD { int sendfile(int fd, int s, off_t offset, \
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 1c361bd..6195321 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -101,7 +101,7 @@ SDT_PROBE_ARGTYPE(vfs, , stat, reg, 1, "int");
static int chroot_refuse_vdir_fds(struct filedesc *fdp);
static int getutimes(const struct timeval *, enum uio_seg, struct timespec *);
-static int setfflags(struct thread *td, struct vnode *, int);
+static int setfflags(struct thread *td, struct vnode *, u_long);
static int setutimes(struct thread *td, struct vnode *,
const struct timespec *, int, int);
static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred,
@@ -2615,7 +2615,7 @@ static int
setfflags(td, vp, flags)
struct thread *td;
struct vnode *vp;
- int flags;
+ u_long flags;
{
int error;
struct mount *mp;
@@ -2657,16 +2657,16 @@ setfflags(td, vp, flags)
*/
#ifndef _SYS_SYSPROTO_H_
struct chflags_args {
- char *path;
- int flags;
+ const char *path;
+ u_long flags;
};
#endif
int
sys_chflags(td, uap)
struct thread *td;
register struct chflags_args /* {
- char *path;
- int flags;
+ const char *path;
+ u_long flags;
} */ *uap;
{
int error;
@@ -2689,8 +2689,8 @@ int
sys_lchflags(td, uap)
struct thread *td;
register struct lchflags_args /* {
- char *path;
- int flags;
+ const char *path;
+ u_long flags;
} */ *uap;
{
int error;
@@ -2713,7 +2713,7 @@ sys_lchflags(td, uap)
#ifndef _SYS_SYSPROTO_H_
struct fchflags_args {
int fd;
- int flags;
+ u_long flags;
};
#endif
int
@@ -2721,7 +2721,7 @@ sys_fchflags(td, uap)
struct thread *td;
register struct fchflags_args /* {
int fd;
- int flags;
+ u_long flags;
} */ *uap;
{
struct file *fp;
diff --git a/sys/sys/stat.h b/sys/sys/stat.h
index ba4f4d4..ec6efae 100644
--- a/sys/sys/stat.h
+++ b/sys/sys/stat.h
@@ -306,7 +306,7 @@ int fchmodat(int, const char *, mode_t, int);
#endif
int fstat(int, struct stat *);
#if __BSD_VISIBLE
-int lchflags(const char *, int);
+int lchflags(const char *, unsigned long);
int lchmod(const char *, mode_t);
#endif
#if __POSIX_VISIBLE >= 200112
diff --git a/tools/regression/pjdfstest/pjdfstest.c b/tools/regression/pjdfstest/pjdfstest.c
index 6eafc8c..b0b083d 100644
--- a/tools/regression/pjdfstest/pjdfstest.c
+++ b/tools/regression/pjdfstest/pjdfstest.c
@@ -831,7 +831,8 @@ call_syscall(struct syscall_desc *scall, char *argv[])
#endif
#ifdef HAS_LCHFLAGS
case ACTION_LCHFLAGS:
- rval = lchflags(STR(0), (int)str2flags(chflags_flags, STR(1)));
+ rval = lchflags(STR(0),
+ (unsigned long)str2flags(chflags_flags, STR(1)));
break;
#endif
case ACTION_TRUNCATE:
OpenPOWER on IntegriCloud