Commit c3d28db7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] ncpfs (1/7): constants sanitized

That's the beginning of ncpfs endianness cleanup.
	* converted fixed-endian constants to little-endian (i.e. replaced
htons(0xCDAB) with cpu_to_le16(0xABCD), etc.).  These guys _are_ little-endian
and make much more sense that way, even aside of annotation issues.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 494c97a2
...@@ -414,7 +414,7 @@ int ncp_obtain_info(struct ncp_server *server, struct inode *dir, char *path, ...@@ -414,7 +414,7 @@ int ncp_obtain_info(struct ncp_server *server, struct inode *dir, char *path,
ncp_add_byte(server, 6); /* subfunction */ ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, server->name_space[volnum]); ncp_add_byte(server, server->name_space[volnum]);
ncp_add_byte(server, server->name_space[volnum]); /* N.B. twice ?? */ ncp_add_byte(server, server->name_space[volnum]); /* N.B. twice ?? */
ncp_add_word(server, htons(0x0680)); /* get all */ ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */
ncp_add_dword(server, RIM_ALL); ncp_add_dword(server, RIM_ALL);
ncp_add_handle_path(server, volnum, dirent, 1, path); ncp_add_handle_path(server, volnum, dirent, 1, path);
...@@ -444,7 +444,7 @@ ncp_obtain_DOS_dir_base(struct ncp_server *server, ...@@ -444,7 +444,7 @@ ncp_obtain_DOS_dir_base(struct ncp_server *server,
ncp_add_byte(server, 6); /* subfunction */ ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, server->name_space[volnum]); ncp_add_byte(server, server->name_space[volnum]);
ncp_add_byte(server, server->name_space[volnum]); ncp_add_byte(server, server->name_space[volnum]);
ncp_add_word(server, htons(0x0680)); /* get all */ ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */
ncp_add_dword(server, RIM_DIRECTORY); ncp_add_dword(server, RIM_DIRECTORY);
ncp_add_handle_path(server, volnum, dirent, 1, path); ncp_add_handle_path(server, volnum, dirent, 1, path);
...@@ -517,7 +517,7 @@ ncp_ObtainSpecificDirBase(struct ncp_server *server, ...@@ -517,7 +517,7 @@ ncp_ObtainSpecificDirBase(struct ncp_server *server,
ncp_add_byte(server, 6); /* subfunction */ ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, nsSrc); ncp_add_byte(server, nsSrc);
ncp_add_byte(server, nsDst); ncp_add_byte(server, nsDst);
ncp_add_word(server, htons(0x0680)); /* get all */ ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */
ncp_add_dword(server, RIM_ALL); ncp_add_dword(server, RIM_ALL);
ncp_add_handle_path(server, vol_num, dir_base, 1, path); ncp_add_handle_path(server, vol_num, dir_base, 1, path);
...@@ -631,7 +631,7 @@ int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server *server, ...@@ -631,7 +631,7 @@ int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server *server,
ncp_add_byte(server, 7); /* subfunction */ ncp_add_byte(server, 7); /* subfunction */
ncp_add_byte(server, server->name_space[volnum]); ncp_add_byte(server, server->name_space[volnum]);
ncp_add_byte(server, 0); /* reserved */ ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, htons(0x0680)); /* search attribs: all */ ncp_add_word(server, cpu_to_le16(0x8006)); /* search attribs: all */
ncp_add_dword(server, info_mask); ncp_add_dword(server, info_mask);
ncp_add_mem(server, info, sizeof(*info)); ncp_add_mem(server, info, sizeof(*info));
...@@ -714,7 +714,7 @@ ncp_del_file_or_subdir2(struct ncp_server *server, ...@@ -714,7 +714,7 @@ ncp_del_file_or_subdir2(struct ncp_server *server,
} }
volnum = NCP_FINFO(inode)->volNumber; volnum = NCP_FINFO(inode)->volNumber;
dirent = NCP_FINFO(inode)->DosDirNum; dirent = NCP_FINFO(inode)->DosDirNum;
return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, htons(0x0680)); return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, cpu_to_le16(0x8006));
} }
int int
...@@ -731,11 +731,11 @@ ncp_del_file_or_subdir(struct ncp_server *server, ...@@ -731,11 +731,11 @@ ncp_del_file_or_subdir(struct ncp_server *server,
result=ncp_obtain_DOS_dir_base(server, volnum, dirent, name, &dirent); result=ncp_obtain_DOS_dir_base(server, volnum, dirent, name, &dirent);
if (result) return result; if (result) return result;
return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, htons(0x0680)); return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, cpu_to_le16(0x8006));
} }
else else
#endif /* CONFIG_NCPFS_NFS_NS */ #endif /* CONFIG_NCPFS_NFS_NS */
return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, server->name_space[volnum], htons(0x0680)); return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, server->name_space[volnum], cpu_to_le16(0x8006));
} }
static inline void ConvertToNWfromDWORD(__u32 sfd, __u8 ret[6]) static inline void ConvertToNWfromDWORD(__u32 sfd, __u8 ret[6])
...@@ -755,7 +755,7 @@ int ncp_open_create_file_or_subdir(struct ncp_server *server, ...@@ -755,7 +755,7 @@ int ncp_open_create_file_or_subdir(struct ncp_server *server,
int desired_acc_rights, int desired_acc_rights,
struct ncp_entry_info *target) struct ncp_entry_info *target)
{ {
__u16 search_attribs = ntohs(0x0600); __u16 search_attribs = cpu_to_le16(0x0006);
__u8 volnum; __u8 volnum;
__u32 dirent; __u32 dirent;
int result; int result;
...@@ -764,7 +764,7 @@ int ncp_open_create_file_or_subdir(struct ncp_server *server, ...@@ -764,7 +764,7 @@ int ncp_open_create_file_or_subdir(struct ncp_server *server,
dirent = NCP_FINFO(dir)->dirEntNum; dirent = NCP_FINFO(dir)->dirEntNum;
if ((create_attributes & aDIR) != 0) { if ((create_attributes & aDIR) != 0) {
search_attribs |= ntohs(0x0080); search_attribs |= cpu_to_le16(0x8000);
} }
ncp_init_request(server); ncp_init_request(server);
ncp_add_byte(server, 1); /* subfunction */ ncp_add_byte(server, 1); /* subfunction */
...@@ -833,7 +833,7 @@ int ncp_search_for_file_or_subdir(struct ncp_server *server, ...@@ -833,7 +833,7 @@ int ncp_search_for_file_or_subdir(struct ncp_server *server,
ncp_add_byte(server, 3); /* subfunction */ ncp_add_byte(server, 3); /* subfunction */
ncp_add_byte(server, server->name_space[seq->volNumber]); ncp_add_byte(server, server->name_space[seq->volNumber]);
ncp_add_byte(server, 0); /* data stream (???) */ ncp_add_byte(server, 0); /* data stream (???) */
ncp_add_word(server, htons(0x0680)); /* Search attribs */ ncp_add_word(server, cpu_to_le16(0x8006)); /* Search attribs */
ncp_add_dword(server, RIM_ALL); /* return info mask */ ncp_add_dword(server, RIM_ALL); /* return info mask */
ncp_add_mem(server, seq, 9); ncp_add_mem(server, seq, 9);
#ifdef CONFIG_NCPFS_NFS_NS #ifdef CONFIG_NCPFS_NFS_NS
...@@ -877,7 +877,7 @@ int ncp_search_for_fileset(struct ncp_server *server, ...@@ -877,7 +877,7 @@ int ncp_search_for_fileset(struct ncp_server *server,
ncp_add_byte(server, 20); ncp_add_byte(server, 20);
ncp_add_byte(server, server->name_space[seq->volNumber]); ncp_add_byte(server, server->name_space[seq->volNumber]);
ncp_add_byte(server, 0); /* datastream */ ncp_add_byte(server, 0); /* datastream */
ncp_add_word(server, htons(0x0680)); ncp_add_word(server, cpu_to_le16(0x8006));
ncp_add_dword(server, RIM_ALL); ncp_add_dword(server, RIM_ALL);
ncp_add_word(server, 32767); /* max returned items */ ncp_add_word(server, 32767); /* max returned items */
ncp_add_mem(server, seq, 9); ncp_add_mem(server, seq, 9);
...@@ -955,14 +955,14 @@ int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, ...@@ -955,14 +955,14 @@ int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct inode *new_dir, char *new_name) struct inode *new_dir, char *new_name)
{ {
int result; int result;
int old_type = htons(0x0600); int old_type = cpu_to_le16(0x06);
/* If somebody can do it atomic, call me... vandrove@vc.cvut.cz */ /* If somebody can do it atomic, call me... vandrove@vc.cvut.cz */
result = ncp_RenameNSEntry(server, old_dir, old_name, old_type, result = ncp_RenameNSEntry(server, old_dir, old_name, old_type,
new_dir, new_name); new_dir, new_name);
if (result == 0xFF) /* File Not Found, try directory */ if (result == 0xFF) /* File Not Found, try directory */
{ {
old_type = htons(0x1600); old_type = cpu_to_le16(0x16);
result = ncp_RenameNSEntry(server, old_dir, old_name, old_type, result = ncp_RenameNSEntry(server, old_dir, old_name, old_type,
new_dir, new_name); new_dir, new_name);
} }
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
/* these magic numbers must appear in the symlink file -- this makes it a bit /* these magic numbers must appear in the symlink file -- this makes it a bit
more resilient against the magic attributes being set on random files. */ more resilient against the magic attributes being set on random files. */
#define NCP_SYMLINK_MAGIC0 le32_to_cpu(0x6c6d7973) /* "symlnk->" */ #define NCP_SYMLINK_MAGIC0 cpu_to_le32(0x6c6d7973) /* "symlnk->" */
#define NCP_SYMLINK_MAGIC1 le32_to_cpu(0x3e2d6b6e) #define NCP_SYMLINK_MAGIC1 cpu_to_le32(0x3e2d6b6e)
/* ----- read a symbolic link ------------------------------------------ */ /* ----- read a symbolic link ------------------------------------------ */
......
...@@ -57,9 +57,9 @@ struct ncp_volume_info { ...@@ -57,9 +57,9 @@ struct ncp_volume_info {
char volume_name[NCP_VOLNAME_LEN + 1]; char volume_name[NCP_VOLNAME_LEN + 1];
}; };
#define AR_READ (ntohs(0x0100)) #define AR_READ (cpu_to_le16(1))
#define AR_WRITE (ntohs(0x0200)) #define AR_WRITE (cpu_to_le16(2))
#define AR_EXCLUSIVE (ntohs(0x2000)) #define AR_EXCLUSIVE (cpu_to_le16(0x20))
#define NCP_FILE_ID_LEN 6 #define NCP_FILE_ID_LEN 6
...@@ -71,20 +71,20 @@ struct ncp_volume_info { ...@@ -71,20 +71,20 @@ struct ncp_volume_info {
#define NW_NS_OS2 4 #define NW_NS_OS2 4
/* Defines for ReturnInformationMask */ /* Defines for ReturnInformationMask */
#define RIM_NAME (ntohl(0x01000000L)) #define RIM_NAME (cpu_to_le32(1))
#define RIM_SPACE_ALLOCATED (ntohl(0x02000000L)) #define RIM_SPACE_ALLOCATED (cpu_to_le32(2))
#define RIM_ATTRIBUTES (ntohl(0x04000000L)) #define RIM_ATTRIBUTES (cpu_to_le32(4))
#define RIM_DATA_SIZE (ntohl(0x08000000L)) #define RIM_DATA_SIZE (cpu_to_le32(8))
#define RIM_TOTAL_SIZE (ntohl(0x10000000L)) #define RIM_TOTAL_SIZE (cpu_to_le32(0x10))
#define RIM_EXT_ATTR_INFO (ntohl(0x20000000L)) #define RIM_EXT_ATTR_INFO (cpu_to_le32(0x20))
#define RIM_ARCHIVE (ntohl(0x40000000L)) #define RIM_ARCHIVE (cpu_to_le32(0x40))
#define RIM_MODIFY (ntohl(0x80000000L)) #define RIM_MODIFY (cpu_to_le32(0x80))
#define RIM_CREATION (ntohl(0x00010000L)) #define RIM_CREATION (cpu_to_le32(0x100))
#define RIM_OWNING_NAMESPACE (ntohl(0x00020000L)) #define RIM_OWNING_NAMESPACE (cpu_to_le32(0x200))
#define RIM_DIRECTORY (ntohl(0x00040000L)) #define RIM_DIRECTORY (cpu_to_le32(0x400))
#define RIM_RIGHTS (ntohl(0x00080000L)) #define RIM_RIGHTS (cpu_to_le32(0x800))
#define RIM_ALL (ntohl(0xFF0F0000L)) #define RIM_ALL (cpu_to_le32(0xFFF))
#define RIM_COMPRESSED_INFO (ntohl(0x00000080L)) #define RIM_COMPRESSED_INFO (cpu_to_le32(0x80000000))
/* Defines for NSInfoBitMask */ /* Defines for NSInfoBitMask */
#define NSIBM_NFS_NAME 0x0001 #define NSIBM_NFS_NAME 0x0001
...@@ -161,19 +161,19 @@ struct nw_info_struct { ...@@ -161,19 +161,19 @@ struct nw_info_struct {
}; };
/* modify mask - use with MODIFY_DOS_INFO structure */ /* modify mask - use with MODIFY_DOS_INFO structure */
#define DM_ATTRIBUTES (ntohl(0x02000000L)) #define DM_ATTRIBUTES (cpu_to_le32(0x02))
#define DM_CREATE_DATE (ntohl(0x04000000L)) #define DM_CREATE_DATE (cpu_to_le32(0x04))
#define DM_CREATE_TIME (ntohl(0x08000000L)) #define DM_CREATE_TIME (cpu_to_le32(0x08))
#define DM_CREATOR_ID (ntohl(0x10000000L)) #define DM_CREATOR_ID (cpu_to_le32(0x10))
#define DM_ARCHIVE_DATE (ntohl(0x20000000L)) #define DM_ARCHIVE_DATE (cpu_to_le32(0x20))
#define DM_ARCHIVE_TIME (ntohl(0x40000000L)) #define DM_ARCHIVE_TIME (cpu_to_le32(0x40))
#define DM_ARCHIVER_ID (ntohl(0x80000000L)) #define DM_ARCHIVER_ID (cpu_to_le32(0x80))
#define DM_MODIFY_DATE (ntohl(0x00010000L)) #define DM_MODIFY_DATE (cpu_to_le32(0x0100))
#define DM_MODIFY_TIME (ntohl(0x00020000L)) #define DM_MODIFY_TIME (cpu_to_le32(0x0200))
#define DM_MODIFIER_ID (ntohl(0x00040000L)) #define DM_MODIFIER_ID (cpu_to_le32(0x0400))
#define DM_LAST_ACCESS_DATE (ntohl(0x00080000L)) #define DM_LAST_ACCESS_DATE (cpu_to_le32(0x0800))
#define DM_INHERITED_RIGHTS_MASK (ntohl(0x00100000L)) #define DM_INHERITED_RIGHTS_MASK (cpu_to_le32(0x1000))
#define DM_MAXIMUM_SPACE (ntohl(0x00200000L)) #define DM_MAXIMUM_SPACE (cpu_to_le32(0x2000))
struct nw_modify_dos_info { struct nw_modify_dos_info {
__u32 attributes __attribute__((packed)); __u32 attributes __attribute__((packed));
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
#define _NCP_NO #define _NCP_NO
/* these define the attribute byte as seen by NCP */ /* these define the attribute byte as seen by NCP */
#define aRONLY (ntohl(0x01000000)) #define aRONLY (__constant_cpu_to_le32(1))
#define aHIDDEN (__constant_ntohl(0x02000000)) #define aHIDDEN (__constant_cpu_to_le32(2))
#define aSYSTEM (__constant_ntohl(0x04000000)) #define aSYSTEM (__constant_cpu_to_le32(4))
#define aEXECUTE (ntohl(0x08000000)) #define aEXECUTE (__constant_cpu_to_le32(8))
#define aDIR (ntohl(0x10000000)) #define aDIR (__constant_cpu_to_le32(0x10))
#define aARCH (ntohl(0x20000000)) #define aARCH (__constant_cpu_to_le32(0x20))
#define aSHARED (ntohl(0x80000000)) #define aSHARED (__constant_cpu_to_le32(0x80))
#define aDONTSUBALLOCATE (ntohl(1L<<(11+8))) #define aDONTSUBALLOCATE (__constant_cpu_to_le32(1L<<11))
#define aTRANSACTIONAL (ntohl(1L<<(12+8))) #define aTRANSACTIONAL (__constant_cpu_to_le32(1L<<12))
#define aPURGE (ntohl(1L<<(16-8))) #define aPURGE (__constant_cpu_to_le32(1L<<16))
#define aRENAMEINHIBIT (ntohl(1L<<(17-8))) #define aRENAMEINHIBIT (__constant_cpu_to_le32(1L<<17))
#define aDELETEINHIBIT (ntohl(1L<<(18-8))) #define aDELETEINHIBIT (__constant_cpu_to_le32(1L<<18))
#define aDONTCOMPRESS (nothl(1L<<(27-24))) #define aDONTCOMPRESS (__constant_cpu_to_le32(1L<<27))
#endif /* _NCP_NO */ #endif /* _NCP_NO */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment