Skip to content

Commit

Permalink
Revert r312923 a better approach will be taken later
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed Jan 28, 2017
1 parent dc5f9fc commit 814aaaa
Show file tree
Hide file tree
Showing 34 changed files with 333 additions and 151 deletions.
2 changes: 1 addition & 1 deletion bin/ed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LINKS= ${BINDIR}/ed ${BINDIR}/red
MLINKS= ed.1 red.1

.if ${MK_OPENSSL} != "no" && ${MK_ED_CRYPTO} != "no"
CFLAGS+=-DDES
CFLAGS+=-DDES -I/usr/include/private/openssl
LIBADD= crypto
.endif

Expand Down
79 changes: 51 additions & 28 deletions contrib/dma/mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <signal.h>
#include <syslog.h>
#include <unistd.h>
#include <ctype.h>

#include "dma.h"

Expand Down Expand Up @@ -341,18 +342,41 @@ parse_addrs(struct parse_state *ps, char *s, struct queue *queue)
goto again;
}

static int
writeline(struct queue *queue, const char *line, ssize_t linelen)
{
ssize_t len;

while (linelen > 0) {
len = linelen;
if (linelen > 1000) {
len = 990;
}
if (fwrite(line, len, 1, queue->mailf) != 1)
return (-1);
if (linelen <= 1000)
break;
if (fwrite("\n", 1, 1, queue->mailf) != 1)
return (-1);
line += 990;
linelen = strlen(line);
}
return (0);
}

int
readmail(struct queue *queue, int nodot, int recp_from_header)
{
struct parse_state parse_state;
char line[1000]; /* by RFC2822 */
size_t linelen;
char *line = NULL;
ssize_t linelen;
size_t linecap = 0;
char newline[1000];
size_t error;
int had_headers = 0;
int had_from = 0;
int had_messagid = 0;
int had_date = 0;
int had_last_line = 0;
int nocopy = 0;

parse_state.state = NONE;
Expand All @@ -372,24 +396,15 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
return (-1);

while (!feof(stdin)) {
if (fgets(line, sizeof(line) - 1, stdin) == NULL)
newline[0] = '\0';
if ((linelen = getline(&line, &linecap, stdin)) <= 0)
break;
if (had_last_line)
errlogx(EX_DATAERR, "bad mail input format:"
" from %s (uid %d) (envelope-from %s)",
username, useruid, queue->sender);
linelen = strlen(line);
if (linelen == 0 || line[linelen - 1] != '\n') {
/*
* This line did not end with a newline character.
* If we fix it, it better be the last line of
* the file.
*/
line[linelen] = '\n';
line[linelen + 1] = 0;
had_last_line = 1;
}
if (!had_headers) {
if (linelen > 1000)
errlogx(EX_DATAERR, "bad mail input format:"
" from %s (uid %d) (envelope-from %s)",
username, useruid, queue->sender);

/*
* Unless this is a continuation, switch of
* the Bcc: nocopy flag.
Expand Down Expand Up @@ -425,36 +440,44 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
}
}

if (strcmp(line, "\n") == 0 && !had_headers) {
if (line[0] == '\n' && !had_headers) {
had_headers = 1;
while (!had_date || !had_messagid || !had_from) {
if (!had_date) {
had_date = 1;
snprintf(line, sizeof(line), "Date: %s\n", rfc822date());
snprintf(newline, sizeof(newline), "Date: %s\n", rfc822date());
} else if (!had_messagid) {
/* XXX msgid, assign earlier and log? */
had_messagid = 1;
snprintf(line, sizeof(line), "Message-Id: <%"PRIxMAX".%s.%"PRIxMAX"@%s>\n",
snprintf(newline, sizeof(newline), "Message-Id: <%"PRIxMAX".%s.%"PRIxMAX"@%s>\n",
(uintmax_t)time(NULL),
queue->id,
(uintmax_t)random(),
hostname());
} else if (!had_from) {
had_from = 1;
snprintf(line, sizeof(line), "From: <%s>\n", queue->sender);
snprintf(newline, sizeof(newline), "From: <%s>\n", queue->sender);
}
if (fwrite(line, strlen(line), 1, queue->mailf) != 1)
return (-1);
if (fwrite(newline, strlen(newline), 1, queue->mailf) != 1)
goto fail;
}
strcpy(line, "\n");
strlcpy(newline, "\n", sizeof(newline));
}
if (!nodot && linelen == 2 && line[0] == '.')
break;
if (!nocopy) {
if (fwrite(line, strlen(line), 1, queue->mailf) != 1)
return (-1);
if (newline[0] != '\0') {
if (fwrite(newline, strlen(newline), 1, queue->mailf) != 1)
goto fail;
} else {
if (writeline(queue, line, linelen) != 0)
goto fail;
}
}
}

return (0);
fail:
free(line);
return (-1);
}
4 changes: 2 additions & 2 deletions share/mk/bsd.doc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ INDXBIB?= indxbib
PIC?= pic
REFER?= refer
.for _dev in ${PRINTERDEVICE:Mascii}
ROFF.ascii?= groff -Tascii -P-c ${TRFLAGS} -mtty-char ${MACROS} ${PAGES:C/^/-o/1}
ROFF.ascii?= nroff -Tascii -P-c ${TRFLAGS} -mtty-char ${MACROS} ${PAGES:C/^/-o/1}
.endfor
.for _dev in ${PRINTERDEVICE:Nascii}
ROFF.${_dev}?= groff -T${_dev} ${TRFLAGS} ${MACROS} ${PAGES:C/^/-o/1}
ROFF.${_dev}?= nroff -T${_dev} ${TRFLAGS} ${MACROS} ${PAGES:C/^/-o/1}
.endfor
SOELIM?= soelim
TBL?= tbl
Expand Down
15 changes: 15 additions & 0 deletions sys/amd64/amd64/db_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ db_nextframe(struct amd64_frame **fp, db_addr_t *ip, struct thread *td)
*fp = (struct amd64_frame *) rbp;
}


static int
db_backtrace(struct thread *td, struct trapframe *tf, struct amd64_frame *frame,
db_addr_t pc, register_t sp, int count)
Expand Down Expand Up @@ -384,6 +385,20 @@ db_trace_self(void)
db_backtrace(curthread, NULL, frame, callpc, 0, -1);
}

void
db_trace_self_depth(int depth)
{
struct amd64_frame *frame;
db_addr_t callpc;
register_t rbp;

__asm __volatile("movq %%rbp,%0" : "=r" (rbp));
frame = (struct amd64_frame *)rbp;
callpc = (db_addr_t)db_get_value((long)&frame->f_retaddr, 8, FALSE);
frame = frame->f_frame;
db_backtrace(curthread, NULL, frame, callpc, 0, depth);
}

int
db_trace_thread(struct thread *thr, int count)
{
Expand Down
2 changes: 2 additions & 0 deletions sys/amd64/cloudabi64/cloudabi64_sysvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
__FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/imgact.h>
#include <sys/kernel.h>
#include <sys/proc.h>
Expand All @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/frame.h>
#include <machine/pcb.h>
#include <machine/vmparam.h>
#include <machine/cpu.h>

#include <compat/cloudabi/cloudabi_util.h>

Expand Down
2 changes: 1 addition & 1 deletion sys/cam/ctl/ctl_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct ctl_lun_io_stats {
uint64_t lun_number;
uint32_t blocksize;
ctl_lun_stats_flags flags;
struct ctl_lun_io_port_stats ports[CTL_MAX_PORTS];
struct ctl_lun_io_port_stats *ports;
};

struct ctl_stats {
Expand Down
2 changes: 2 additions & 0 deletions sys/cddl/dev/fbt/x86/fbt_isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <sys/dtrace.h>

#include <machine/cpu.h>

#include "fbt.h"

#define FBT_PUSHL_EBP 0x55
Expand Down
1 change: 1 addition & 0 deletions sys/compat/cloudabi/cloudabi_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/seq.h>
#include <sys/systm.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
Expand Down
1 change: 1 addition & 0 deletions sys/compat/cloudabi64/cloudabi64_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
__FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/syscallsubr.h>

Expand Down
8 changes: 8 additions & 0 deletions sys/compat/linuxkpi/common/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ struct linux_kmem_cache {
};

#define SLAB_HWCACHE_ALIGN 0x0001
static inline void *
kmalloc_array(size_t n, size_t size, gfp_t flags)
{
if (size != 0 && n > SIZE_MAX / size)
return (NULL);
return kmalloc(n * size, flags);
}
}

static inline int
linux_kmem_ctor(void *mem, int size, void *arg, int flags)
Expand Down
40 changes: 33 additions & 7 deletions sys/contrib/dev/acpica/components/namespace/nsxfeval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,23 +1022,25 @@ ACPI_EXPORT_SYMBOL (AcpiDetachData)

/*******************************************************************************
*
* FUNCTION: AcpiGetData
* FUNCTION: AcpiGetDataFull
*
* PARAMETERS: ObjHandle - Namespace node
* Handler - Handler used in call to AttachData
* Handle - Handler used in call to attach_data
* Data - Where the data is returned
* Callback - function to execute before returning
*
* RETURN: Status
*
* DESCRIPTION: Retrieve data that was previously attached to a namespace node.
* DESCRIPTION: Retrieve data that was previously attached to a namespace node
* and execute a callback before returning.
*
******************************************************************************/

ACPI_STATUS
AcpiGetData (
AcpiGetDataFull (
ACPI_HANDLE ObjHandle,
ACPI_OBJECT_HANDLER Handler,
void **Data)
void **Data,
void (*Callback)(void *))
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
Expand Down Expand Up @@ -1069,10 +1071,34 @@ AcpiGetData (
}

Status = AcpiNsGetAttachedData (Node, Handler, Data);

if (ACPI_SUCCESS(Status) && Callback) {
Callback(*Data);
}
UnlockAndExit:
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
ACPI_EXPORT_SYMBOL (AcpiGetDataFull)

/*******************************************************************************
*
* FUNCTION: AcpiGetData
*
* PARAMETERS: ObjHandle - Namespace node
* Handler - Handler used in call to AttachData
* Data - Where the data is returned
*
* RETURN: Status
*
* DESCRIPTION: Retrieve data that was previously attached to a namespace node.
*
******************************************************************************/
ACPI_STATUS
AcpiGetData (
ACPI_HANDLE ObjHandle,
ACPI_OBJECT_HANDLER Handler,
void **Data)
{
return (AcpiGetDataFull(ObjHandle, Handler, Data, NULL));
}
ACPI_EXPORT_SYMBOL (AcpiGetData)
8 changes: 8 additions & 0 deletions sys/contrib/dev/acpica/include/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ AcpiGetData (
ACPI_OBJECT_HANDLER Handler,
void **Data))

ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
AcpiGetDataFull (
ACPI_HANDLE Object,
ACPI_OBJECT_HANDLER Handler,
void **Data,
void (*Callback)(void *)))

ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
AcpiDebugTrace (
Expand Down
1 change: 1 addition & 0 deletions sys/ddb/ddb.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ bool db_stop_at_pc(int type, int code, bool *is_breakpoint,
bool *is_watchpoint);
#define db_strcpy strcpy
void db_trace_self(void);
void db_trace_self_depth(int);
int db_trace_thread(struct thread *, int);
bool db_value_of_name(const char *name, db_expr_t *valuep);
bool db_value_of_name_pcpu(const char *name, db_expr_t *valuep);
Expand Down
14 changes: 8 additions & 6 deletions sys/dev/drm2/drm_agpsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
__FBSDID("$FreeBSD$");

#include <dev/drm2/drmP.h>
#include <linux/slab.h>

#if __OS_HAS_AGP

Expand Down Expand Up @@ -209,13 +208,15 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)

if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
if (!(entry = malloc(sizeof(*entry), DRM_MEM_AGPLISTS, M_NOWAIT)))
return -ENOMEM;

memset(entry, 0, sizeof(*entry));

pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request->type;
if (!(memory = agp_alloc_memory(dev->agp->bridge, type, pages << PAGE_SHIFT))) {
kfree(entry);
free(entry, DRM_MEM_AGPLISTS);
return -ENOMEM;
}

Expand Down Expand Up @@ -375,7 +376,7 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
list_del(&entry->head);

drm_free_agp(entry->memory, entry->pages);
kfree(entry);
free(entry, DRM_MEM_AGPLISTS);
return 0;
}
EXPORT_SYMBOL(drm_agp_free);
Expand Down Expand Up @@ -403,11 +404,12 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
{
struct drm_agp_head *head = NULL;

if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
if (!(head = malloc(sizeof(*head), DRM_MEM_AGPLISTS, M_NOWAIT)))
return NULL;
memset((void *)head, 0, sizeof(*head));
head->bridge = agp_find_device();
if (!head->bridge) {
kfree(head);
free(head, DRM_MEM_AGPLISTS);
return NULL;
} else {
agp_get_info(head->bridge, &head->agp_info);
Expand Down
Loading

0 comments on commit 814aaaa

Please sign in to comment.